Files
FixIt/assets/lib/mapbox-gl/mapbox-gl.js
T
2026-09-01 13:56:15 +08:00

48 lines
1.8 MiB
Plaintext
Vendored
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory());
})(this, (function () { 'use strict';
let shared, worker, mapboxgl;
if (typeof self !== "undefined") self.__mapboxImport = (u) => import(
/* webpackIgnore: true */
/* @vite-ignore */
u
);
function define(_, chunk) {
if (!shared) {
shared = chunk;
} else if (!worker) {
worker = chunk;
} else {
const sharedChunk = {};
shared(void 0, sharedChunk);
mapboxgl = chunk(sharedChunk);
const workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; self.__mapboxImport = (u) => import(u); (" + shared + ")(undefined, sharedChunk); (" + worker + ")(undefined, sharedChunk); self.onerror = null;";
if (typeof window !== "undefined" && window && window.URL && window.URL.createObjectURL) {
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" }));
}
}
}
define(["require","exports"],function(e,t){var i="3.29.0",n=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function o(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=i*o-r*n;return a?(e[0]=o*(a=1/a),e[1]=-n*a,e[2]=-r*a,e[3]=i*a,e):null}function a(){var e=new r(9);return r!=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 s(e,t,i){var n=t[0],r=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=i[0],f=i[1],p=i[2],_=i[3],m=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*n+f*a+p*u,e[1]=d*r+f*s+p*c,e[2]=d*o+f*l+p*h,e[3]=_*n+m*a+g*u,e[4]=_*r+m*s+g*c,e[5]=_*o+m*l+g*h,e[6]=y*n+x*a+v*u,e[7]=y*r+x*s+v*c,e[8]=y*o+x*l+v*h,e}function l(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function u(){var e=new r(16);return r!=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 c(e){var t=new r(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 h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function d(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 f(e,t){if(e===t){var i=t[1],n=t[2],r=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=r,e[13]=a,e[14]=s;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function p(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],_=t[13],m=t[14],g=t[15],y=i*s-n*a,x=i*l-r*a,v=i*u-o*a,b=n*l-r*s,w=n*u-o*s,E=r*u-o*l,A=c*_-h*p,I=c*m-d*p,T=c*g-f*p,M=h*m-d*_,S=h*g-f*_,z=d*g-f*m,R=y*z-x*S+v*M+b*T-w*I+E*A;return R?(e[0]=(s*z-l*S+u*M)*(R=1/R),e[1]=(r*S-n*z-o*M)*R,e[2]=(_*E-m*w+g*b)*R,e[3]=(d*w-h*E-f*b)*R,e[4]=(l*T-a*z-u*I)*R,e[5]=(i*z-r*T+o*I)*R,e[6]=(m*v-p*E-g*x)*R,e[7]=(c*E-d*v+f*x)*R,e[8]=(a*S-s*T+u*A)*R,e[9]=(n*T-i*S-o*A)*R,e[10]=(p*w-_*v+g*y)*R,e[11]=(h*v-c*w-f*y)*R,e[12]=(s*I-a*M-l*A)*R,e[13]=(i*M-n*I+r*A)*R,e[14]=(_*x-p*b-m*y)*R,e[15]=(c*b-h*x+d*y)*R,e):null}function _(e,t,i){var n=t[0],r=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],_=t[12],m=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*n+v*s+b*h+w*_,e[1]=x*r+v*l+b*d+w*m,e[2]=x*o+v*u+b*f+w*g,e[3]=x*a+v*c+b*p+w*y,e[4]=(x=i[4])*n+(v=i[5])*s+(b=i[6])*h+(w=i[7])*_,e[5]=x*r+v*l+b*d+w*m,e[6]=x*o+v*u+b*f+w*g,e[7]=x*a+v*c+b*p+w*y,e[8]=(x=i[8])*n+(v=i[9])*s+(b=i[10])*h+(w=i[11])*_,e[9]=x*r+v*l+b*d+w*m,e[10]=x*o+v*u+b*f+w*g,e[11]=x*a+v*c+b*p+w*y,e[12]=(x=i[12])*n+(v=i[13])*s+(b=i[14])*h+(w=i[15])*_,e[13]=x*r+v*l+b*d+w*m,e[14]=x*o+v*u+b*f+w*g,e[15]=x*a+v*c+b*p+w*y,e}function m(e,t,i){var n,r,o,a,s,l,u,c,h,d,f,p,_=i[0],m=i[1],g=i[2];return t===e?(e[12]=t[0]*_+t[4]*m+t[8]*g+t[12],e[13]=t[1]*_+t[5]*m+t[9]*g+t[13],e[14]=t[2]*_+t[6]*m+t[10]*g+t[14],e[15]=t[3]*_+t[7]*m+t[11]*g+t[15]):(r=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=n*_+s*m+h*g+t[12],e[13]=r*_+l*m+d*g+t[13],e[14]=o*_+u*m+f*g+t[14],e[15]=a*_+c*m+p*g+t[15]),e}function g(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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 y(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=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*r+u*n,e[5]=a*r+c*n,e[6]=s*r+h*n,e[7]=l*r+d*n,e[8]=u*r-o*n,e[9]=c*r-a*n,e[10]=h*r-s*n,e[11]=d*r-l*n,e}function x(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=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*r-u*n,e[1]=a*r-c*n,e[2]=s*r-h*n,e[3]=l*r-d*n,e[8]=o*n+u*r,e[9]=a*n+c*r,e[10]=s*n+h*r,e[11]=l*n+d*r,e}function v(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=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*r+u*n,e[1]=a*r+c*n,e[2]=s*r+h*n,e[3]=l*r+d*n,e[4]=u*r-o*n,e[5]=c*r-a*n,e[6]=h*r-s*n,e[7]=d*r-l*n,e}function b(e,t){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]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function w(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function E(e,t,i){var r,o,a,s=i[0],l=i[1],u=i[2],c=Math.sqrt(s*s+l*l+u*u);return c<n?null:(s*=c=1/c,l*=c,u*=c,r=Math.sin(t),o=Math.cos(t),e[0]=s*s*(a=1-o)+o,e[1]=l*s*a+u*r,e[2]=u*s*a-l*r,e[3]=0,e[4]=s*l*a-u*r,e[5]=l*l*a+o,e[6]=u*l*a+s*r,e[7]=0,e[8]=s*u*a+l*r,e[9]=l*u*a-s*r,e[10]=u*u*a+o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function A(e,t){var i=t[0],n=t[1],r=t[2],o=t[4],a=t[5],s=t[6],l=t[8],u=t[9],c=t[10];return e[0]=Math.sqrt(i*i+n*n+r*r),e[1]=Math.sqrt(o*o+a*a+s*s),e[2]=Math.sqrt(l*l+u*u+c*c),e}function I(e,t){var i=new r(3);A(i,t);var n=1/i[0],o=1/i[1],a=1/i[2],s=t[0]*n,l=t[1]*o,u=t[2]*a,c=t[4]*n,h=t[5]*o,d=t[6]*a,f=t[8]*n,p=t[9]*o,_=t[10]*a,m=s+h+_,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(f-u)/g,e[2]=(l-c)/g):s>h&&s>_?(g=2*Math.sqrt(1+s-h-_),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(l+c)/g,e[2]=(f+u)/g):h>_?(g=2*Math.sqrt(1+h-s-_),e[3]=(f-u)/g,e[0]=(l+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+_-s-h),e[3]=(l-c)/g,e[0]=(f+u)/g,e[1]=(d+p)/g,e[2]=.25*g),e}function T(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=i+i,s=n+n,l=r+r,u=i*a,c=n*a,h=n*s,d=r*a,f=r*s,p=r*l,_=o*a,m=o*s,g=o*l;return e[0]=1-h-p,e[1]=c+g,e[2]=d-m,e[3]=0,e[4]=c-g,e[5]=1-u-p,e[6]=f+_,e[7]=0,e[8]=d+m,e[9]=f-_,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}var M=function(e,t,i,n,r){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!=r&&r!==1/0){var a=1/(n-r);e[10]=(r+n)*a,e[14]=2*r*n*a;}else e[10]=-1,e[14]=-2*n;return e},S=function(e,t,i,n,r,o,a){var s=1/(t-i),l=1/(n-r),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+i)*s,e[13]=(r+n)*l,e[14]=(a+o)*u,e[15]=1,e},z=_;function R(){var e=new r(3);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function P(e){var t=new r(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function D(e){var t=e[0],i=e[1],n=e[2];return Math.sqrt(t*t+i*i+n*n)}function C(e,t,i){var n=new r(3);return n[0]=e,n[1]=t,n[2]=i,n}function F(e,t,i,n){return e[0]=t,e[1]=i,e[2]=n,e}function O(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function L(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function B(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function N(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function V(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function k(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function U(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e}function G(e,t){var i=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return Math.sqrt(i*i+n*n+r*r)}function j(e,t){var i=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return i*i+n*n+r*r}function H(e){var t=e[0],i=e[1],n=e[2];return t*t+i*i+n*n}function $(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Z(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;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 W(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function q(e,t,i){var n=t[0],r=t[1],o=t[2],a=i[0],s=i[1],l=i[2];return e[0]=r*l-o*s,e[1]=o*a-n*l,e[2]=n*s-r*a,e}function X(e,t,i,n){var r=t[0],o=t[1],a=t[2];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=a+n*(i[2]-a),e}function Y(e,t,i){var n=t[0],r=t[1],o=t[2],a=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(a=a||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/a,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/a,e}function J(e,t,i){var n=t[0],r=t[1],o=t[2];return e[0]=n*i[0]+r*i[3]+o*i[6],e[1]=n*i[1]+r*i[4]+o*i[7],e[2]=n*i[2]+r*i[5]+o*i[8],e}function K(e,t,i){var n=i[0],r=i[1],o=i[2],a=i[3],s=t[0],l=t[1],u=t[2],c=r*u-o*l,h=o*s-n*u,d=n*l-r*s;return e[0]=s+a*(c+=c)+r*(d+=d)-o*(h+=h),e[1]=l+a*h+o*c-n*d,e[2]=u+a*d+n*h-r*c,e}function Q(e){return e[0]=0,e[1]=0,e[2]=0,e}function ee(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var te=L,ie=B,ne=D;function re(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function oe(e,t,i,n){var o=new r(4);return o[0]=e,o[1]=t,o[2]=i,o[3]=n,o}function ae(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function se(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=i*i+n*n+r*r+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=i*a,e[1]=n*a,e[2]=r*a,e[3]=o*a,e}function le(e,t,i){var n=t[0],r=t[1],o=t[2],a=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*a,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*a,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*a,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*a,e}function ue(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ce(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function he(e,t){var i=2*Math.acos(t[3]),r=Math.sin(i/2);return r>n?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i}function de(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=n*l+a*s,e[1]=r*l+o*s,e[2]=o*l-r*s,e[3]=a*l-n*s,e}function fe(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=n*l-o*s,e[1]=r*l+a*s,e[2]=o*l+n*s,e[3]=a*l-r*s,e}function pe(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=n*l+r*s,e[1]=r*l-n*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e}R(),re();var _e,me,ge,ye=se,xe=(_e=R(),me=C(1,0,0),ge=C(0,1,0),function(e,t,i){var n=W(t,i);return n<-.999999?(q(_e,me,t),ne(_e)<1e-6&&q(_e,ge,t),Z(_e,_e),function(e,t,i){i*=.5;var n=Math.sin(i);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i);}(e,_e,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(q(_e,t,i),e[0]=_e[0],e[1]=_e[1],e[2]=_e[2],e[3]=1+n,ye(e,e))});function ve(){var e=new r(2);return r!=Float32Array&&(e[0]=0,e[1]=0),e}function be(e,t){var i=new r(2);return i[0]=e,i[1]=t,i}function we(e,t,i){return e[0]=t,e[1]=i,e}function Ee(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function Ae(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function Ie(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function Te(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function Me(e,t){var i=t[0],n=t[1],r=i*i+n*n;return r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e}function Se(e,t){return e[0]*t[0]+e[1]*t[1]}ue(),ue(),a();var ze=Ae;function Re(e,t,i,n){const r=3*e,o=3*(i-e)-r,a=1-r-o,s=3*t,l=3*(n-t)-s,u=1-s-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let n=0;n<8;n++){const n=((a*i+o)*i+r)*i-e;if(Math.abs(n)<t)return ((u*i+l)*i+s)*i;const c=(3*a*i+2*o)*i+r;if(Math.abs(c)<1e-6)break;i-=n/c;}let n=0,c=1;i=e;for(let s=0;s<20;s++){const s=((a*i+o)*i+r)*i;if(Math.abs(s-e)<t)break;e>s?n=i:c=i,i=.5*(n+c);}return ((u*i+l)*i+s)*i}}function Pe(e,t){this.x=e,this.y=t;}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;const i=e,n=t;if(Object.keys(i).length!==Object.keys(n).length)return !1;for(const e in i)if(!De(i[e],n[e]))return !1;return !0}return e===t}function Ce(e,t,i=0,n=e.length-1,r=Oe){for(;n>i;){if(n-i>600){const o=n-i+1,a=t-i+1,s=Math.log(o),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);Ce(e,t,Math.max(i,Math.floor(t-a*l/o+u)),Math.min(n,Math.floor(t+(o-a)*l/o+u)),r);}const o=e[t];let a=i,s=n;for(Fe(e,i,t),r(e[n],o)>0&&Fe(e,i,n);a<s;){for(Fe(e,a,s),a++,s--;r(e[a],o)<0;)a++;for(;r(e[s],o)>0;)s--;}0===r(e[i],o)?Fe(e,i,s):(s++,Fe(e,s,n)),s<=t&&(i=s+1),t<=s&&(n=s-1);}}function Fe(e,t,i){const n=e[t];e[t]=e[i],e[i]=n;}function Oe(e,t){return e<t?-1:e>t?1:0}function Le(e){let t=0;for(let i,n,r=0,o=e.length,a=o-1;r<o;a=r++)i=e[r],n=e[a],t+=(n.x-i.x)*(i.y+n.y);return t}function Be(e,t){return t.area-e.area}function Ne(e,t){const i=e.length;if(i<=1)return [e];const n=[];let r,o;for(let t=0;t<i;t++){const i=Le(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(r&&n.push(r),r=[e[t]]):r.push(e[t]));}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++){const i=n[e];i.length<=t||(Ce(i,t,1,i.length-1,Be),n[e]=i.slice(0,t));}return n}function Ve(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 ke(e,t){return !(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Ue(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],a=e[1]-i[1];return n*a-o*r===0&&n*o<=0&&r*a<=0}function Ge(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function je(e,t,i=!1){let n=!1;for(let r=0,o=t.length;r<o;r++){const o=t[r];for(let t=0,r=o.length,a=r-1;t<r;a=t++){const r=o[a],s=o[t];if(Ue(e,r,s))return i;Ge(e,r,s)&&(n=!n);}}return n}function He(e,t,i,n){const r=n[0]-i[0],o=n[1]-i[1],a=(e[0]-i[0])*o-r*(e[1]-i[1]),s=(t[0]-i[0])*o-r*(t[1]-i[1]);return a>0&&s<0||a<0&&s>0}function $e(e,t,i,n){return 0!==(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!He(e,t,i,n)||!He(i,n,e,t));var r,o;}function Ze(e){const t=new Pe(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Pe(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),i.x<n.x&&(i.x=n.x),i.y<n.y&&(i.y=n.y);return {min:t,max:i}}ve(),Pe.prototype={clone(){return new Pe(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),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Pe},Pe.convert=function(e){if(e instanceof Pe)return e;if(Array.isArray(e))return new Pe(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Pe(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const We=Math.PI/180,qe=180/Math.PI,Xe=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Ye(e){return e*We}function Je(e){return e*qe}const Ke=[[0,0],[1,0],[1,1],[0,1]];function Qe(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)}const et=Re(.25,.1,.25,1);function tt(e,t,i){return Math.min(i,Math.max(t,e))}function it(e,t,i){return (i=tt((i-e)/(t-e),0,1))*i*(3-2*i)}function nt(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function rt(e,t,i){if(!e.length)return i(null,[]);let n=e.length;const r=new Array(e.length);let o=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(o=e),r[a]=t,0===--n&&i(o,r);});});}function ot(e,t){const i={};for(let n=0;n<t.length;n++){const r=t[n];r in e&&(i[r]=e[r]);}return i}let at=1;function st(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function lt(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function ut(e){return !!e&&Xe.test(e)}function ct(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t));});}function ht(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function dt(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function ft(e){return Array.isArray(e)?e.map(ft):"object"==typeof e&&e?ht(e,ft):e}function pt(e,t){for(let i=0;i<e.length;i++)if(t.includes(e[i]))return !0;return !1}const _t={};function mt(e){_t[e]||("undefined"!=typeof console&&console.warn(e),_t[e]=!0);}function gt(e,t,i){return (i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function yt([e,t,i]){const n=Ye(t+90),r=Ye(i);return {x:e*Math.cos(n)*Math.sin(r),y:e*Math.sin(n)*Math.sin(r),z:e*Math.cos(r),azimuthal:t,polar:i}}function xt(e,t,i){const n=Math.sqrt(e*e+t*t+i*i),r=n>0?Math.acos(i/n)*qe:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*qe+90:0;return o<0&&(o+=360),[n,o,r]}function vt(e){return ("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function bt(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;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}function wt(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}}function Et(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return !1}}function At(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function It(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3];}function Tt(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]}function Mt(e){return e>0?1/(1.001-e):1+e}function St(e){return e>0?1-1/(1.001-e):-e}function zt(e,t,i){return (e-t.min)*(i.max-i.min)/(t.max-t.min)+i.min}function Rt(e){return e*e*e*e*e}function Pt(e){return e>>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296}let Dt,Ct,Ft,Ot,Lt,Bt;function Nt(){return Dt??=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap,Dt}const Vt={requestIdleCallback:e=>{if("undefined"!=typeof requestIdleCallback)return requestIdleCallback(e);setTimeout(()=>e({didTimeout:!1,timeRemaining:()=>50}),0);},now:()=>void 0!==Ot?Ot:performance.now(),setNow(e){Ot=e;},restoreNow(){Ot=void 0;},frame(e){const t=requestAnimationFrame(e);return {cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:n}=e;Lt||(Lt=document.createElement("canvas"));const r=Lt.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return (i>Lt.width||n>Lt.height)&&(Lt.width=i,Lt.height=n),r.clearRect(-t,-t,i+2*t,n+2*t),r.drawImage(e,0,0,i,n),r.getImageData(-t,-t,i+2*t,n+2*t)},resolveURL:e=>(Ct||(Ct=document.createElement("a")),Ct.href=e,Ct.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(Ft??=window.matchMedia("(prefers-reduced-motion: reduce)"),Ft.matches)},hasCanvasFingerprintNoise(){if(void 0!==Bt)return Bt;if(!Nt())return Bt=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n<e.width;++n)t.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,t.fillRect(n,0,1,1);const n=t.getImageData(0,0,e.width,e.height);i=0;for(let e=0;e<n.data.length;++e)if(e%4!=3&&i++!==n.data[e])return Bt=!0,!0;return Bt=!1,!1}};let kt;const Ut={API_URL:"https://api.mapbox.com",API_URL_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i,API_TILEJSON_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i,API_SPRITE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i,API_FONTS_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i,API_STYLE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i,API_CDN_URL_REGEX:/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i,get EVENTS_URL(){if(!Ut.API_URL)return null;try{const e=new URL(Ut.API_URL);return "api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v1.2.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v1.2.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function Gt(){return new URL(Ut.DRACO_URL,Ut.API_URL).href}function jt(){if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(void 0===kt){if("object"!=typeof WebAssembly)return !1;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);kt=WebAssembly.validate(e);}return kt}()?Ut.MESHOPT_SIMD_URL:Ut.MESHOPT_URL,Ut.API_URL).href}function Ht(){return new URL(Ut.BUILDING_GEN_URL,Ut.API_URL).href}function $t(e,t){const i=e.indexOf("?"),n=i<0?e:e.slice(0,i),r=new URLSearchParams(i<0?"":e.slice(i));for(const[e,i]of Object.entries(t))r.set(e,i);return `${n}?${r}`}function Zt(e,t={persistentParams:[]}){const i=e.indexOf("?");if(i<0)return e;const n=new URLSearchParams,r=new URLSearchParams(e.slice(i));for(const e of t.persistentParams){const t=r.get(e);t&&n.set(e,t);}const o=n.toString();return `${e.slice(0,i)}${o.length>0?`?${o}`:""}`}const Wt="mapbox-tiles";let qt=500,Xt=50;const Yt=["language","worldview","jobid"];let Jt;function Kt(){try{return caches}catch(e){}}function Qt(){const e=Kt();e&&null==Jt&&(Jt=e.open(Wt));}let ei=1/0;function ti(e){return Ut.API_URL_REGEX.test(e)}function ii(e){return 0===e.indexOf("mapbox:")}function ni(e){return Ut.API_CDN_URL_REGEX.test(e)}function ri(e){return Ut.API_SPRITE_REGEX.test(e)}function oi(e){return Ut.API_STYLE_REGEX.test(e)&&!ri(e)}const ai={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(ai);class si extends Error{constructor(e,t,i){super(),this.url=i,this.statusText=e,this.status=t;}get message(){return 401===this.status&&ti(this.url)?`${this.statusText}: you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/guides/#access-tokens-and-token-scopes`:this.statusText}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}function li(e){return "object"==typeof e&&null!==e&&"status"in e&&404===e.status}const ui=vt()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,ci=/^\w+:/,hi=/[\r\n]+/;async function di(e,t){let i;return i="arrayBuffer"===e.type?await t.arrayBuffer():"json"===e.type?await t.json():await t.text(),{data:i,headers:t.headers}}async function fi(e,t){return t&&t.throwIfAborted(),(i=e.url).startsWith("file:")||ui().startsWith("file:")&&!ci.test(i)?async function(e,t){return new Promise((i,n)=>{const r=new XMLHttpRequest,o=()=>{t.removeEventListener("abort",o),r.abort(),n(t.reason);};t&&t.addEventListener("abort",o),r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t&&t.removeEventListener("abort",o),n(new Error(r.statusText));},r.onload=()=>{if(t&&t.removeEventListener("abort",o),(r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let t=r.response;if("json"===e.type)try{t=JSON.parse(r.response);}catch(e){return void n(e)}const o=new Headers;r.getAllResponseHeaders().trim().split(hi).forEach(e=>{const t=e.split(": "),i=t.shift(),n=t.join(": ");i&&o.set(i,n);}),i({data:t,headers:o});}else n(new si(r.statusText,r.status,e.url));},r.send(e.body);})}(e,t):async function(e,t){const i=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ui(),referrerPolicy:e.referrerPolicy,signal:t}),n=(r=i.url).indexOf("sku=")>0&&ti(r);var r;if("json"===e.type&&i.headers.set("Accept","application/json"),n){let n=null;try{n=await async function(e){if(Qt(),null==Jt)return null;const t=await Jt;let i=Zt(e.url,{persistentParams:Yt});const n=e.headers.get("Range");n&&(i=$t(i,{range:n}));const r=await t.match(i);if(!r)return null;const o=function(e){if(!e)return !1;const t=new Date(e.headers.get("expires")||0),i=bt(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!i["no-cache"]}(r);return t.delete(i).catch(e=>mt(e.message)),o&&t.put(i,r.clone()).catch(e=>mt(e.message)),{response:r,fresh:o}}(i);}catch(e){"SecurityError"!==e.message&&mt(e.toString());}if(n&&n.fresh)return t&&t.throwIfAborted(),di(e,n.response)}const o=Date.now();let a;try{a=await fetch(i);}catch(t){if("AbortError"===t.name)throw t;throw new Error(`${t.message} ${e.url}`,{cause:t})}if(t&&t.throwIfAborted(),!a.ok)throw new si(a.statusText,a.status,e.url);const s=n?a.clone():null,l=await di(e,a);return s&&async function(e,t,i){if(Qt(),null==Jt)return;const n=bt(t.headers.get("cache-control")||"");if(n["no-store"])return;const r={status:t.status,statusText:t.statusText,headers:new Headers(t.headers)};n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const o=r.headers.get("expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let a=Zt(e.url,{persistentParams:Yt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;r.status=200,a=$t(a,{range:t});}const s=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,r);var l;if(Qt(),null!=Jt)try{const e=await Jt;await e.put(a,s);}catch(e){mt(e.message);}}(i,s,o),l}(e,t);var i;}async function pi(e,t){return fi(Object.assign(e,{type:"json"}),t)}async function _i(e,t){return fi(Object.assign(e,{type:"arrayBuffer"}),t)}function mi(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let gi,yi;gi=[],yi=0;const xi="01",vi={create:"create",load:"load",fullLoad:"fullLoad"},bi={mark(e){performance.mark(e);},measure(e,t,i){performance.measure(e,t,i);}};function wi(e){const t=e.name.split("?")[0];return ni(t)&&t.includes("mapbox-gl.js")?"javascript":ni(t)&&t.includes("mapbox-gl.css")?"css":function(e){return Ut.API_FONTS_REGEX.test(e)}(t)?"fontRange":ri(t)?"sprite":oi(t)?"style":function(e){return Ut.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const Ei=/(\.(png|jpg)\d*)(?=$)/,Ai=/^.+\/v4\//,Ii=/\.[\w]+$/,Ti=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,Mi=/^access_token=(.*)$/,Si="NO_ACCESS_TOKEN",zi=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ri(e){const t=e.match(zi);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Pi(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const Di="mapbox.eventData";function Ci(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}function Fi(e){return !(!Ut.EVENTS_URL||!e&&!Ut.ACCESS_TOKEN)}let Oi;const Li=/^[\w.+-]+(\/[\w.+-]+)?$/;let Bi="other";class Ni{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=!1;}getStorageKey(e){const t=Ci(Ut.ACCESS_TOKEN);let i="";return i=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):Ut.ACCESS_TOKEN||"",e?`${Di}.${e}:${i}`:`${Di}:${i}`}fetchEventData(){const e=Et("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.getStorageKey("uuidTimestamp");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=localStorage.getItem(i);r&&(this.anonId=r);const o=localStorage.getItem(n);o&&(this.anonIdTimestamp=Number(o));const a=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<a)&&this.refreshUUID();}catch(e){mt("Unable to read from LocalStorage");}}refreshUUID(){this.anonId=st(),this.anonIdTimestamp=Date.now();}saveEventData(){const e=Et("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.getStorageKey("uuidTimestamp"),r=this.anonId,o=this.anonIdTimestamp;if(e&&r)try{localStorage.setItem(i,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData)),o&&localStorage.setItem(n,o.toString());}catch(e){mt("Unable to write to LocalStorage");}}processRequests(){}postEvent(e,t,i,n){if(!Ut.EVENTS_URL)return;const r=Ri(Ut.EVENTS_URL);r.params.push(`access_token=${n||Ut.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString()},a=t?Object.assign(o,t):o,s={url:Pi(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=!0,async function(e){return fi(Object.assign(e,{method:"POST"}),void 0)}(s).then(()=>{this.pendingRequest=!1,i(null),this.saveEventData(),this.processRequests();}).catch(e=>{this.pendingRequest=!1,i(e),this.saveEventData(),this.processRequests();});}queueRequest(e,t){this.queue.push({...e,customAccessToken:t}),this.processRequests();}}class Vi extends Ni{constructor(e){super("metrics"),e&&(this.data=e);}postMetricsEvent(e){if(!Fi(e))return;this.anonId||this.fetchEventData(),ut(this.anonId)||this.refreshUUID();const t={...this.data,sessionId:this.anonId};this.queueRequest({timestamp:Date.now(),payload:t},e);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:t,customAccessToken:i}=this.queue.shift();this.postEvent(e,t,()=>{},i);}}const ki=new class extends Ni{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(e,t){Fi(t)&&Array.isArray(e)&&e.some(e=>ii(e)||ti(e))&&this.queueRequest({timestamp:Date.now()},t);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=Ci(Ut.ACCESS_TOKEN),t=e?e.u:Ut.ACCESS_TOKEN;let n=t!==this.eventData.tokenU;ut(this.anonId)||(this.refreshUUID(),n=!0);const{timestamp:r,customAccessToken:o}=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(r),i=(r-this.eventData.lastSuccess)/864e5;n=n||i>=1||i<-1||e.getDate()!==t.getDate();}else n=!0;if(!n)return void this.processRequests();const a={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:xi,"enabled.telemetry":!1,userId:this.anonId,bundleFormat:"umd",bundleDistribution:Bi};Oi&&(a.sdkInfo=Oi),this.postEvent(r,a,e=>{e||(this.eventData.lastSuccess=r,this.eventData.tokenU=t);},o);}},Ui=ki.postTurnstileEvent.bind(ki),Gi=new class extends Ni{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(e,t,i,n){this.skuToken=t,this.errorCb=n,Ut.EVENTS_URL&&(i||Ut.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Si)));}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:t,customAccessToken:n}=this.queue.shift();if(e&&this.success[e])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),ut(this.anonId)||this.refreshUUID();const r={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:xi,skuToken:this.skuToken,userId:this.anonId,bundleFormat:"umd",bundleDistribution:Bi};Oi&&(r.sdkInfo=Oi),this.postEvent(t,r,t=>{t?this.errorCb(t):e&&(this.success[e]=!0);},n);}remove(){this.errorCb=null;}},ji=Gi.postMapLoadEvent.bind(Gi),Hi=new class extends Ni{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=st(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:n,importedStyles:r}=t;if(!Fi(e))return;const o=this.getMapInstanceId(i),a={mapInstanceId:o,eventId:this.getEventId(o),style:n};r.length&&(a.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:a},e);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:t,customAccessToken:i}=this.queue.shift();this.postEvent(e,t,()=>{},i);}},$i=Hi.postStyleLoadEvent.bind(Hi),Zi=new Vi({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Wi=Zi.postMetricsEvent.bind(Zi),qi=new Vi({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Xi=qi.postMetricsEvent.bind(qi),Yi=new class extends Ni{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){Fi(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,performanceData:t,customAccessToken:n}=this.queue.shift(),r=function(e){const t=performance.getEntriesByType("resource"),n=performance.getEntriesByType("mark"),r=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const n of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,a=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,n.startTime),t[r]=Math.max(t[r]||-1/0,n.responseEnd);const s=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==n.transferSize&&0===n.transferSize&&s(a),s(o);}return t}(function(e,t){const i={};if(e)for(const n of e){const e=t(n);void 0===i[e]&&(i[e]=[]),i[e].push(n);}return i}(t,wi)),o=window.devicePixelRatio,a=navigator.connection||navigator.mozConnection||navigator.webkitConnection,s=a?a.effectiveType:void 0,l={counters:[],metadata:[],attributes:[]},u=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in r)u(l.counters,e,r[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(l.counters,"interactionRangeMin",e.interactionRange[0]),u(l.counters,"interactionRangeMax",e.interactionRange[1])),n)for(const e of Object.values(vi)){const t=n.find(t=>t.name===e);t&&u(l.counters,e,t.startTime);}return u(l.counters,"visibilityHidden",e.visibilityHidden),u(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(oi(e)){const t=e.split("/").slice(-2);if(2===t.length)return `mapbox://styles/${t[0]}/${t[1]}`}}}(t)),u(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(l.attributes,"projection",e.projection),u(l.attributes,"zoom",e.zoom),u(l.metadata,"devicePixelRatio",o),u(l.metadata,"connectionEffectiveType",s),u(l.metadata,"navigatorUserAgent",navigator.userAgent),u(l.metadata,"screenWidth",window.screen.width),u(l.metadata,"screenHeight",window.screen.height),u(l.metadata,"windowWidth",window.innerWidth),u(l.metadata,"windowHeight",window.innerHeight),u(l.metadata,"mapWidth",e.width/o),u(l.metadata,"mapHeight",e.height/o),u(l.metadata,"webglRenderer",e.renderer),u(l.metadata,"webglVendor",e.vendor),u(l.metadata,"sdkVersion",i),u(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(t);for(const e of r.metadata);for(const e of r.counters);for(const e of r.attributes);this.postEvent(e,r,()=>{},n);}},Ji=Yi.postPerformanceEvent.bind(Yi),Ki=new class extends Ni{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(e,t,i,n){if(!Ut.API_URL||!Ut.SESSION_PATH)return;const r=Ri(Ut.API_URL+Ut.SESSION_PATH);r.params.push(`sku=${t||""}`),r.params.push(`access_token=${n||Ut.ACCESS_TOKEN||""}`);const o={url:Pi(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=!0,async function(e){return fi(Object.assign(e,{method:"GET"}),void 0)}(o).then(()=>{this.pendingRequest=!1,i(null),this.saveEventData(),this.processRequests();}).catch(e=>{this.pendingRequest=!1,i(e),this.saveEventData(),this.processRequests();});}getSessionAPI(e,t,i,n){this.skuToken=t,this.errorCb=n,Ut.EVENTS_URL&&Ut.SESSION_PATH&&Ut.API_URL&&(i||Ut.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Si)));}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:t,customAccessToken:i}=this.queue.shift();e&&this.success[e]||this.getSession(t,this.skuToken,t=>{t?this.errorCb(t):e&&(this.success[e]=!0);},i);}remove(){this.errorCb=null;}},Qi=Ki.getSessionAPI.bind(Ki),en=new Set;function tn(e,t=0){const i=3432918353,n=461845907,r=e.length,o=r-(3&r);let a,s=0|t,l=0;for(;l<o;)a=255&e.charCodeAt(l)|(255&e.charCodeAt(l+1))<<8|(255&e.charCodeAt(l+2))<<16|(255&e.charCodeAt(l+3))<<24,l+=4,a=Math.imul(a,i),a=a<<15|a>>>17,a=Math.imul(a,n),s^=a,s=s<<13|s>>>19,s=Math.imul(s,5)+3864292196|0;a=0;const u=3&r;return u>0&&(u>=3&&(a^=(255&e.charCodeAt(l+2))<<16),u>=2&&(a^=(255&e.charCodeAt(l+1))<<8),a^=255&e.charCodeAt(l),a=Math.imul(a,i),a=a<<15|a>>>17,a=Math.imul(a,n),s^=a),s^=r,s^=s>>>16,s=Math.imul(s,2246822507),s^=s>>>13,s=Math.imul(s,3266489909),s^=s>>>16,s>>>0}class nn{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e;}}class rn extends nn{constructor(e,t={}){super("error",{error:e,...t}),this.error=e;}}function on(e,t,i){i[e]&&i[e].includes(t)||(i[e]=i[e]||[],i[e].push(t));}function an(e,t,i){if(i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1);}}class sn{constructor(){this._listeners={},this._oneTimeListeners={};}on(e,t){return on(e,t,this._listeners),this}off(e,t){return an(e,t,this._listeners),an(e,t,this._oneTimeListeners),this}once(e,t){return t?(on(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t);})}fire(e,t){const i="string"==typeof e?new nn(e,t):e,n=i.type;if(this.listens(n)){i.target=this;const e=this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)an(n,e,this._oneTimeListeners),e.call(this,i);const r=this._eventedParent;if(r){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(i,e),r.fire(i);}}else i instanceof rn&&console.error(i.error);return this}listens(e){return !!(this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class ln{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId);}static from(e){return new ln(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,i]=e.split("");return new ln({name:t,iconsetId:i})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ln.toString(this)}serialize(){return {name:this.name,iconsetId:this.iconsetId}}}var un,cn={},hn=function(){if(un)return cn;un=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return (e=Math.round(e))<0?0:e>255?255:e}function i(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function r(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{cn.parseCSSColor=function(o){var a,s=o.replace(/ /g,"").toLowerCase();if(s in e)return e[s].slice();if("#"===s[0])return 4===s.length?(a=parseInt(s.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===s.length&&(a=parseInt(s.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case "rgba":if(4!==h.length)return null;d=n(h.pop());case "rgb":return 3!==h.length?null:[i(h[0]),i(h[1]),i(h[2]),d];case "hsla":if(4!==h.length)return null;d=n(h.pop());case "hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,p=n(h[1]),_=n(h[2]),m=_<=.5?_*(p+1):_+p-_*p,g=2*_-m;return [t(255*r(g,m,f+1/3)),t(255*r(g,m,f)),t(255*r(g,m,f-1/3)),d];default:return null}}return null};}catch(e){}return cn}();function dn(e,t,i){return e*(1-i)+t*i}const fn=new Map;class pn{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n;}static parse(e){if(!e)return;if(e instanceof pn)return e;if("string"!=typeof e)return;const t=fn.get(e);if(t)return t;const i=hn.parseCSSColor(e);if(!i)return;const n=new pn(i[0]/255,i[1]/255,i[2]/255,i[3]);return fn.set(e,n),n}toString(){const{r:e,g:t,b:i,a:n}=this;return `rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*i)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:i,b:n,a:r}=this;return new mn(e,t,i,n,r)}toPremultipliedRenderColor(e){const{r:t,g:i,b:n,a:r}=this;return new gn(e,t*r,i*r,n*r,r)}clone(){return new pn(this.r,this.g,this.b,this.a)}}class _n{constructor(e,t,i,n,r,o=!1){if(this.premultiplied=!1,this.premultiplied=o,e){const o=e.image.height,a=o*o;this.premultiplied?(t=0===r?0:t/r*(o-1),i=0===r?0:i/r*(o-1),n=0===r?0:n/r*(o-1)):(t*=o-1,i*=o-1,n*=o-1),t=Math.max(0,Math.min(o-1,t)),i=Math.max(0,Math.min(o-1,i)),n=Math.max(0,Math.min(o-1,n));const s=Math.floor(t),l=Math.floor(i),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(n),f=t-s,p=i-l,_=n-u,m=e.image.data,g=4*(s+l*a+u*o),y=4*(s+l*a+d*o),x=4*(s+h*a+u*o),v=4*(s+h*a+d*o),b=4*(c+l*a+u*o),w=4*(c+l*a+d*o),E=4*(c+h*a+u*o),A=4*(c+h*a+d*o);this.r=dn(dn(dn(m[g],m[y],_),dn(m[x],m[v],_),p),dn(dn(m[b],m[w],_),dn(m[E],m[A],_),p),f)/255*(this.premultiplied?r:1),this.g=dn(dn(dn(m[g+1],m[y+1],_),dn(m[x+1],m[v+1],_),p),dn(dn(m[b+1],m[w+1],_),dn(m[E+1],m[A+1],_),p),f)/255*(this.premultiplied?r:1),this.b=dn(dn(dn(m[g+2],m[y+2],_),dn(m[x+2],m[v+2],_),p),dn(dn(m[b+2],m[w+2],_),dn(m[E+2],m[A+2],_),p),f)/255*(this.premultiplied?r:1),this.a=r;}else this.r=t,this.g=i,this.b=n,this.a=r;}toArray(){const{r:e,g:t,b:i,a:n}=this;return [255*e,255*t,255*i,n]}toHslaArray(){let{r:e,g:t,b:i,a:n}=this;if(this.premultiplied){if(0===n)return [0,0,0,0];const r=1/n;e*=r,t*=r,i*=r;}const r=Math.min(Math.max(e,0),1),o=Math.min(Math.max(t,0),1),a=Math.min(Math.max(i,0),1),s=Math.min(r,o,a),l=Math.max(r,o,a),u=l-s,c=.5*(s+l);if(0===u)return [0,0,100*c,n];const h=c>.5?u/(2-l-s):u/(l+s);let d;switch(l){case r:d=60*((o-a)/u+(o<a?6:0));break;case o:d=60*((a-r)/u+2);break;default:d=60*((r-o)/u+4);}return [d,100*h,100*c,n]}toArray01(){const{r:e,g:t,b:i,a:n}=this;return [e,t,i,n]}toArray01Scaled(e){const{r:t,g:i,b:n}=this;return [t*e,i*e,n*e]}toArray01Linear(){const{r:e,g:t,b:i,a:n}=this;return [Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(i,2.2),n]}}class mn extends _n{constructor(e,t,i,n,r){super(e,t,i,n,r,!1);}}class gn extends _n{constructor(e,t,i,n,r){super(e,t,i,n,r,!0);}}function yn(e,t,i){return e.map((e,n)=>dn(e,t[n],i))}pn.black=new pn(0,0,0,1),pn.white=new pn(1,1,1,1),pn.transparent=new pn(0,0,0,0),pn.red=new pn(1,0,0,1),pn.blue=new pn(0,0,1,1);var xn=Object.freeze({__proto__:null,array:yn,color:function(e,t,i){return new pn(dn(e.r,t.r,i),dn(e.g,t.g,i),dn(e.b,t.b,i),dn(e.a,t.a,i))},number:dn});class vn extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}class bn{constructor(e,t=[]){this.parent=e,this.bindings=Object.create(null);for(const[e,i]of t)this.bindings[e]=i;}concat(e){return new bn(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 wn={kind:"null"},En={kind:"number"},An={kind:"string"},In={kind:"boolean"},Tn={kind:"color"},Mn={kind:"object"},Sn={kind:"value"},zn={kind:"collator"},Rn={kind:"formatted"},Pn={kind:"resolvedImage"};function Dn(e,t){return {kind:"array",itemType:e,N:t}}function Cn(e){if("array"===e.kind){const t=Cn(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Fn=[wn,En,An,In,Tn,Rn,Mn,Dn(Sn),Pn];function On(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!On(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 Fn)if(!On(e,t))return null}return `Expected ${Cn(e)} but found ${Cn(t)} instead.`}function Ln(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 Bn(e,t){return "array"===e.kind&&"array"===t.kind?e.N===t.N&&Bn(e.itemType,t.itemType):e.kind===t.kind}class Nn{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}}class Vn{constructor(e,t,i,n,r){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r;}}class kn{constructor(e){this.sections=e;}static fromString(e){return new kn([new Vn(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof kn?e:kn.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const i=t.image.getPrimary().id.toString();e.push(["image",i]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(i);}return e}}class Un{constructor(e,t={}){this.id=ln.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1;}toString(){return JSON.stringify(this)}static parse(e){let t,i,n,r;try{({id:t,params:i,sx:n,sy:r}=JSON.parse(e)||{});}catch(e){return null}return t?new Un(t,{params:i,sx:n,sy:r}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class Gn{constructor(e,t,i,n,r=!1){this.primaryId=ln.from(e),this.primaryOptions=t,i&&(this.secondaryId=ln.from(i)),this.secondaryOptions=n,this.available=r;}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return !!this.primaryId}getPrimary(){return new Un(this.primaryId,this.primaryOptions)}hasSecondary(){return !!this.secondaryId}getSecondary(){return this.secondaryId?new Un(this.secondaryId,this.secondaryOptions):null}static from(e){return "string"!=typeof e?e:Gn.build({name:e})}static build(e,t,i,n){return !e||"object"==typeof e&&!("name"in e)?null:new Gn(e,i,t,n)}}function jn(e,t,i,n){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Hn(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof pn)return !0;if(e instanceof Nn)return !0;if(e instanceof kn)return !0;if(e instanceof Gn)return !0;if(Array.isArray(e)){for(const t of e)if(!Hn(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!Hn(e[t]))return !1;return !0}return !1}function $n(e){if(null===e)return wn;if("string"==typeof e)return An;if("boolean"==typeof e)return In;if("number"==typeof e)return En;if(e instanceof pn)return Tn;if(e instanceof Nn)return zn;if(e instanceof kn)return Rn;if(e instanceof Gn)return Pn;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=$n(t);if(i){if(i===e)continue;i=Sn;break}i=e;}return Dn(i||Sn,t)}return Mn}function Zn(e){return null===e?"":"string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):e instanceof kn||e instanceof Gn||e instanceof pn?e.toString():JSON.stringify(e)}class Wn{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(!Hn(e[1]))return t.error("invalid value");const i=e[1];let n=$n(i);const r=t.expectedType;return "array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Wn(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof pn?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof kn?this.value.serialize():this.value}}class qn{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}}const Xn={string:An,number:En,boolean:In,object:Mn};class Yn{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Xn)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Xn[i],n++;}else r=Sn;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],n++;}i=Dn(r,o);}else i=Xn[r];const o=[];for(;n<e.length;n++){const i=t.parse(e[n],n,Sn);if(!i)return null;o.push(i);}return new Yn(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!On(this.type,$n(i)))return i;if(t===this.args.length-1)throw new qn(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Cn($n(i))} but was expected to be of type ${Cn(this.type)}.`)}return null}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n);}}return t.concat(this.args.map(e=>e.serialize()))}}class Jn{constructor(e){this.type=Rn,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parseObjectValue(o["font-scale"],i,"font-scale",En),!e))return null;let a=null;if(o["text-font"]&&(a=t.parseObjectValue(o["text-font"],i,"text-font",Dn(An)),!a))return null;let s=null;if(o["text-color"]&&(s=t.parseObjectValue(o["text-color"],i,"text-color",Tn),!s))return null;const l=n.at(-1);l.scale=e,l.font=a,l.textColor=s;}else {const o=t.parse(e[i],i,Sn);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null});}}return new Jn(n)}evaluate(e){return new kn(this.sections.map(t=>{const i=t.content.evaluate(e);return Bn($n(i),Pn)?new Vn("",i,null,null,null):new Vn(Zn(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.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);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i);}return e}}class Kn{constructor(e,t,i,n){this._imageWarnHistory={},this.type=Pn,this.namePrimary=e,this.nameSecondary=t,i&&(this.paramsPrimary=i.params,this.iconsetIdPrimary=i.iconset?i.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0);}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let i=1;const n=[];function r(){if(i<e.length){const r=t.parse(e[i],i++,An);return r?(n.push({image:r,options:{}}),!0):(t.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return !0}function o(){if(i<e.length){const o=e[i];if(null===(r=o)||"object"!=typeof r||Array.isArray(r))return !0;const a=o.params,s=o.iconset,l=t.concat(i);if(!a&&!s)return i++,!0;if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const e={},t=l.concat(void 0,"params");for(const i in a){if(!i)return t.error("Image parameter name should be non-empty"),!1;const n=t.concat(void 0,i).parse(a[i],void 0,Tn,void 0,{typeAnnotation:"coerce"});if(!n)return !1;e[i]=n;}n.at(-1).options.params=e;}if(s){if("object"!=typeof s||s.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!s.id)return l.error('Image options "iconset" should have an "id" property'),!1;n.at(-1).options.iconset=s;}return i++,!0}var r;return !0}for(let e=0;e<2;e++)if(!r()||!o())return;return new Kn(n[0].image,n[1]?n[1].image:void 0,n[0].options,n[1]?n[1].options:void 0)}evaluateParams(e,t){const i={};if(t){for(const n in t)if(t[n])try{i[n]=t[n].evaluate(e);}catch(e){continue}if(0!==Object.keys(i).length)return {params:i}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},i=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,n=Gn.build(t,i,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(n&&e.availableImages){const t=n.getPrimary().id;if(n.available=e.availableImages.some(e=>ln.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>ln.isEqual(e,t)));}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t]);}outputDefined(){return !1}serializeOptions(e,t){const i={};if(t&&(i.iconset={id:t}),e){i.params={};for(const t in e)e[t]&&(i.params[t]=e[t].serialize());}return Object.keys(i).length>0?i:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t);}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t);}return e}}function Qn(e){return tr(e)?"string":ir(e)?"number":nr(e)?"boolean":Array.isArray(e)?"array":null===e?"null":er(e)?"object":typeof e}function er(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function tr(e){return "string"==typeof e||e instanceof String}function ir(e){return "number"==typeof e||e instanceof Number}function nr(e){return "boolean"==typeof e||e instanceof Boolean}const rr={"to-boolean":In,"to-color":Tn,"to-number":En,"to-string":An};class or{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],n=[];let r=wn;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);r=Dn(t.expectedType.itemType,i);}else {if(!(i>0&&Hn(e[1][0])))return null;r=Dn($n(e[1][0]),i);}for(let o=0;o<i;o++){const i=e[1][o];let a;if(Array.isArray(i))a=t.parse(i,void 0,r.itemType);else {const e=Qn(i);if(e!==r.itemType.kind)return t.error(`Expected ${r.itemType.kind} but found ${e}.`);a=t.registry.literal.parse(["literal",void 0===i?null:i],t);}if(!a)return null;n.push(a);}}else {if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");r=rr[i];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,Sn);if(!r)return null;n.push(r);}}return new or(r,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const n of this.args){if(t=n.evaluate(e),i=null,t instanceof pn)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 rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:jn(t[0],t[1],t[2],t[3]),!i))return new pn(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new qn(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new qn(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?kn.fromString(Zn(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Gn.build(Zn(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):Zn(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Jn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Kn(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize());}),e}}const ar=["Unknown","Point","LineString","Polygon"];class sr{constructor(e,t,i){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=i;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?ar[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){return pn.parse(e)}getConfig(e){return this.options?this.options.get(e):null}}class lr{constructor(e,t,i,n,r){this.name=e,this.type=t,this._evaluate=i,this.args=n,this._overloadIndex=r;}evaluate(e){if(!this._evaluate){const e=lr.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const i=e[0],n=lr.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let s=null,l=-1;for(const[n,u]of o){if(Array.isArray(n)&&n.length!==e.length-1)continue;a.push(n),l++,null===s?s=t._forkForSignature():s.errors.length=0;const o=[];let c=!1;for(let t=1;t<e.length;t++){const i=e[t],r=Array.isArray(n)?n[t-1]:n.type,a=s.parse(i,1+o.length,r);if(!a){c=!0;break}o.push(a);}if(!c)if(Array.isArray(n)&&n.length!==o.length)s.error(`Expected ${n.length} arguments, but found ${o.length} instead.`);else {for(let e=0;e<o.length;e++){const t=Array.isArray(n)?n[e]:n.type;s.checkSubtype(t,o[e].type,e+1);}if(0===s.errors.length)return new lr(i,r,u,o,l)}}if(1===a.length)t.errors.push(...s.errors);else {const i=(a.length?a:o.map(([e])=>e)).map(ur).join(" | "),n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],1+n.length);if(!r)return null;n.push(Cn(r.type));}t.error(`Expected arguments of type ${i}, but found (${n.join(", ")}) instead.`);}return null}static register(e,t){lr.definitions=t;for(const i in t)e[i]=lr;}}function ur(e){return Array.isArray(e)?`(${e.map(Cn).join(", ")})`:`(${Cn(e.type)}...)`}class cr{constructor(e,t,i){this.type=zn,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t;}static parse(e,t){if(2!==e.length)return t.error("Expected one argument."),null;const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object."),null;const n=void 0===i["case-sensitive"]?t.parse(!1,1,In):t.parseObjectValue(i["case-sensitive"],1,"case-sensitive",In);if(!n)return null;const r=void 0===i["diacritic-sensitive"]?t.parse(!1,1,In):t.parseObjectValue(i["diacritic-sensitive"],1,"diacritic-sensitive",In);if(!r)return null;let o=null;return i.locale&&(o=t.parseObjectValue(i.locale,1,"locale",An),!o)?null:new cr(n,r,o)}evaluate(e){return new Nn(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}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function hr(e){return (180+e)/360}function dr(e){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function fr(e){return 360*e-180}function pr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}const _r=8192;function mr(e,t){const i=hr(e[0]),n=dr(e[1]),r=Math.pow(2,t.z);return [Math.round(i*r*_r),Math.round(n*r*_r)]}function gr(e,t){for(let i=0;i<t.length;i++)if(je(e,t[i]))return !0;return !1}function yr(e,t,i){for(const n of i)for(let i=0,r=n.length,o=r-1;i<r;o=i++)if($e(e,t,n[o],n[i]))return !0;return !1}function xr(e,t){for(let i=0;i<e.length;++i)if(!je(e[i],t))return !1;for(let i=0;i<e.length-1;++i)if(yr(e[i],e[i+1],t))return !1;return !0}function vr(e,t){for(let i=0;i<t.length;i++)if(xr(e,t[i]))return !0;return !1}function br(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=[];for(let n=0;n<e[r].length;n++){const a=mr(e[r][n],i);Ve(t,a),o.push(a);}n.push(o);}return n}function wr(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=br(e[r],t,i);n.push(o);}return n}function Er(e,t,i,n){if(e[0]<i[0]||e[0]>i[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r;}Ve(t,e);}function Ar(e,t,i,n){const r=Math.pow(2,n.z)*_r,o=[n.x*_r,n.y*_r],a=[];if(!e)return a;for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Er(n,t,i,r),a.push(n);}return a}function Ir(e,t,i,n){const r=Math.pow(2,n.z)*_r,o=[n.x*_r,n.y*_r],a=[];if(!e)return a;for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Ve(t,i),e.push(i);}a.push(e);}if(t[2]-t[0]<=r/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const n of e)Er(n,t,i,r);}var s;return a}class Tr{constructor(e,t){this.type=In,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(Hn(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Tr(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Tr(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Tr(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return !1;if("Polygon"===t.type){const o=br(t.coordinates,n,r),a=Ar(e.geometry(),i,n,r);if(!ke(i,n))return !1;for(const e of a)if(!je(e,o))return !1}if("MultiPolygon"===t.type){const o=wr(t.coordinates,n,r),a=Ar(e.geometry(),i,n,r);if(!ke(i,n))return !1;for(const e of a)if(!gr(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return !1;if("Polygon"===t.type){const o=br(t.coordinates,n,r),a=Ir(e.geometry(),i,n,r);if(!ke(i,n))return !1;for(const e of a)if(!xr(e,o))return !1}if("MultiPolygon"===t.type){const o=wr(t.coordinates,n,r),a=Ir(e.geometry(),i,n,r);if(!ke(i,n))return !1;for(const e of a)if(!vr(e,o))return !1}return !0}(e,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}serialize(){return ["within",this.geojson]}}class Mr{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,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r;}t[e]=n;}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1);const o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],r)>=0)break;t[e]=t[n],e=n;}t[e]=r;}}var Sr=8192;function zr(e,t,i){return [e,t,i].filter(Boolean).join("")}function Rr(e,t){switch(e){case "string":return Zn(t);case "number":return +t;case "boolean":return !!t;case "color":return pn.parse(t);case "formatted":return kn.fromString(Zn(t));case "resolvedImage":return Gn.build(Zn(t))}return t}function Pr(e,t,i,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&e<t&&(e=t),void 0!==i&&e>i&&(e=i),e}class Dr{constructor(e,t,i,n=!1){this.type=e,this.key=t,this.scope=i,this.featureConstant=n;}static parse(e,t){let i=t.expectedType;if(i??=Sn,e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof Wn))return t.error("Key name of 'config' expression must be a string literal.");let r,o=!0;const a=Zn(n.value);if(e.length>=3){const i=t.parse(e[2],2);if(!(i instanceof Wn))return t.error("Scope of 'config' expression must be a string literal.");r=Zn(i.value);}if(t.options){const e=zr(a,r,t._scope),i=t.options.get(e);i&&(o=Cr(i.value||i.default));}return new Dr(i,a,r,o)}evaluate(e){const t=zr(this.key,this.scope,e.scope),i=e.getConfig(t);if(!i)return null;const{type:n,value:r,values:o,minValue:a,maxValue:s,stepValue:l}=i,u=i.default.evaluate(e);let c=u;if(r){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),c=r.evaluate(e),e.scope=t;}return n&&(c=Rr(n,c)),void 0===c||void 0===a&&void 0===s&&void 0===l||("number"==typeof c?c=Pr(c,a,s,l):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?Pr(e,a,s,l):e))),void 0!==r&&void 0!==c&&o&&!o.includes(c)&&(c=u,n&&(c=Rr(n,c))),(n&&n!==this.type||void 0!==c&&!Bn($n(c),this.type))&&(c=Rr(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}function Cr(e){if(e instanceof lr){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(e.name.startsWith("filter-"))return !1}if(e instanceof Tr)return !1;if(e instanceof vo)return !1;if(e instanceof Dr)return e.featureConstant;let t=!0;return e.eachChild(e=>{t&&!Cr(e)&&(t=!1);}),t}function Fr(e){if(e instanceof lr&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild(e=>{t&&!Fr(e)&&(t=!1);}),t}function Or(e,t){if(e instanceof lr&&t.has(e.name))return !1;let i=!0;return e.eachChild(e=>{i&&!Or(e,t)&&(i=!1);}),i}function Lr(e,t){return Or(e,new Set(t))}const Br=1/298.257223563,Nr=Br*(2-Br),Vr=Math.PI/180;function kr(e){const t=6378.137*Vr*1e3,i=Math.cos(e*Vr),n=1/(1-Nr*(1-i*i)),r=Math.sqrt(n);return [t*r*i,t*r*n*(1-Nr)]}function Ur(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}function Gr(e,t,i,n){const r=Ur(e[0]-t[0])*i,o=(e[1]-t[1])*n;return Math.sqrt(r*r+o*o)}function jr(e,t,i,n,r){let o=t[0],a=t[1],s=Ur(i[0]-o)*n,l=(i[1]-a)*r;if(0!==s||0!==l){const t=(Ur(e[0]-o)*n*s+(e[1]-a)*r*l)/(s*s+l*l);t>1?(o=i[0],a=i[1]):t>0&&(o+=s/n*t,a+=l/r*t);}return s=Ur(e[0]-o)*n,l=(e[1]-a)*r,Math.sqrt(s*s+l*l)}function Hr(e,t){return t.dist-e.dist}function $r(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return !1;return !0}function Zr(e){return e[1]-e[0]+1}function Wr(e,t){const i=e[1]>=e[0]&&e[1]<t;return i||console.warn("Distance Expression: Index is out of range"),i}function qr(e,t){if(e[0]>e[1])return [null,null];const i=Zr(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 t=Math.floor(i/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function Xr(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!Wr(t,e.length))return i;for(let n=t[0];n<=t[1];++n)Ve(i,e[n]);return i}function Yr(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;i<e.length;++i)for(let n=0;n<e[i].length;++n)Ve(t,e[i][n]);return t}function Jr(e,t,i,n){if($r(e)||$r(t))return NaN;let r=0,o=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(o=e[1]-t[3]),e[3]<t[1]&&(o=t[1]-e[3]),Gr([0,0],[r,o],i,n)}function Kr(e,t,i=8192){const n=Math.pow(2,t.z),r=(e.y/i+t.y)/n;return [fr((e.x/i+t.x)/n),pr(r)]}function Qr(e,t){const i=[];for(let n=0;n<e.length;++n)i.push(Kr(e[n],t));return i}function eo(e,t,i,n){const r=function(e,t,i,n){let r=1/0,o=e[0][0],a=e[0][1];for(let s=0;s<e.length-1;s++){let l=e[s][0],u=e[s][1],c=Ur(e[s+1][0]-l)*i,h=(e[s+1][1]-u)*n,d=0;0===c&&0===h||(d=(Ur(t[0]-l)*i*c+(t[1]-u)*n*h)/(c*c+h*h),d>1?(l=e[s+1][0],u=e[s+1][1]):d>0&&(l+=c/i*d,u+=h/n*d)),c=Ur(t[0]-l)*i,h=(t[1]-u)*n;const f=c*c+h*h;f<r&&(r=f,o=l,a=u);}return [o,a]}(t,e,i,n);return Gr(e,r,i,n)}function to(e,t,i,n,r,o){const a=i.slice(n[0],n[1]+1);let s=1/0;for(let i=t[0];i<=t[1];++i)if(0===(s=Math.min(s,eo(e[i],a,r,o))))return 0;return s}function io(e,t,i,n,r,o){const a=Math.min(jr(e,i,n,r,o),jr(t,i,n,r,o)),s=Math.min(jr(i,e,t,r,o),jr(n,e,t,r,o));return Math.min(a,s)}function no(e,t,i,n,r,o){if(!Wr(t,e.length)||!Wr(n,i.length))return NaN;let a=1/0;for(let s=t[0];s<t[1];++s)for(let t=n[0];t<n[1];++t){if($e(e[s],e[s+1],i[t],i[t+1]))return 0;a=Math.min(a,io(e[s],e[s+1],i[t],i[t+1],r,o));}return a}function ro(e,t,i,n,r,o){if(!Wr(t,e.length)||!Wr(n,i.length))return NaN;let a=1/0;for(let s=t[0];s<=t[1];++s)for(let t=n[0];t<=n[1];++t)if(0===(a=Math.min(a,Gr(e[s],i[t],r,o))))return a;return a}function oo(e,t,i,n){if(je(e,t,!0))return 0;let r=1/0;for(const o of t){const t=o.length;if(t<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(o[0]!==o[t-1]&&0===(r=Math.min(r,jr(e,o[t-1],o[0],i,n))))return r;if(0===(r=Math.min(r,eo(e,o,i,n))))return r}return r}function ao(e,t,i,n,r){if(!Wr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(je(e[n],i,!0))return 0;let o=1/0;for(let a=t[0];a<t[1];++a)for(const t of i)for(let i=0,s=t.length,l=s-1;i<s;l=i++){if($e(e[a],e[a+1],t[l],t[i]))return 0;o=Math.min(o,io(e[a],e[a+1],t[l],t[i],n,r));}return o}function so(e,t){for(const i of e)for(let e=0;e<=i.length-1;++e)if(je(i[e],t,!0))return !0;return !1}function lo(e,t,i,n,r=1/0){const o=Yr(e),a=Yr(t);if(r!==1/0&&Jr(o,a,i,n)>=r)return r;if(ke(o,a)){if(so(e,t))return 0}else if(so(t,e))return 0;let s=r;for(const r of e)for(let e=0,o=r.length,a=o-1;e<o;a=e++)for(const o of t)for(let t=0,l=o.length,u=l-1;t<l;u=t++){if($e(r[a],r[e],o[u],o[t]))return 0;s=Math.min(s,io(r[a],r[e],o[u],o[t],i,n));}return s}function uo(e,t,i,n,r,o,a,s){if(null===a||null===s)return;const l=Jr(Xr(r,a),Xr(o,s),i,n);l<t&&e.push({dist:l,range1:a,range2:s});}function co(e,t,i,n,r,o=1/0){let a=Math.min(Gr(e[0],i[0][0],n,r),o);if(0===a)return a;const s=new Mr([{dist:0,range1:[0,e.length-1],range2:[0,0]}],Hr),l=t?50:100,u=Yr(i);for(;s.length;){const o=s.pop();if(o.dist>=a)continue;const c=o.range1;if(Zr(c)<=l){if(!Wr(c,e.length))return NaN;if(t){const t=ao(e,c,i,n,r);if(0===(a=Math.min(a,t)))return a}else for(let t=c[0];t<=c[1];++t){const o=oo(e[t],i,n,r);if(0===(a=Math.min(a,o)))return a}}else {const i=qr(c,t);if(null!==i[0]){const t=Jr(Xr(e,i[0]),u,n,r);t<a&&s.push({dist:t,range1:i[0],range2:[0,0]});}if(null!==i[1]){const t=Jr(Xr(e,i[1]),u,n,r);t<a&&s.push({dist:t,range1:i[1],range2:[0,0]});}}}return a}function ho(e,t,i,n,r,o,a=1/0){let s=Math.min(a,Gr(e[0],i[0],r,o));if(0===s)return s;const l=new Mr([{dist:0,range1:[0,e.length-1],range2:[0,i.length-1]}],Hr),u=t?50:100,c=n?50:100;for(;l.length;){const a=l.pop();if(a.dist>=s)continue;const h=a.range1,d=a.range2;if(Zr(h)<=u&&Zr(d)<=c){if(!Wr(h,e.length)||!Wr(d,i.length))return NaN;if(t&&n?s=Math.min(s,no(e,h,i,d,r,o)):t||n?t&&!n?s=Math.min(s,to(i,d,e,h,r,o)):!t&&n&&(s=Math.min(s,to(e,h,i,d,r,o))):s=Math.min(s,ro(e,h,i,d,r,o)),0===s)return s}else {const a=qr(h,t),u=qr(d,n);uo(l,s,r,o,e,i,a[0],u[0]),uo(l,s,r,o,e,i,a[0],u[1]),uo(l,s,r,o,e,i,a[1],u[0]),uo(l,s,r,o,e,i,a[1],u[1]);}}return s}function fo(e,t,i,n,r,o=1/0){let a=o;const s=Xr(e,[0,e.length-1]);for(const o of i)if(!(a!==1/0&&Jr(s,Xr(o,[0,o.length-1]),n,r)>=a)&&(a=Math.min(a,ho(e,t,o,!0,n,r,a)),0===a))return a;return a}function po(e,t,i,n,r,o=1/0){let a=o;const s=Xr(e,[0,e.length-1]);for(const o of i){if(a!==1/0&&Jr(s,Yr(o),n,r)>=a)continue;const i=co(e,t,o,n,r,a);if(isNaN(i))return i;if(0===(a=Math.min(a,i)))return a}return a}function _o(e,t,i){const n=[];for(const i of e)for(const e of i)n.push(Kr(e,t));const[r,o]=kr(n[0][1]);return "Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type?ho(n,!1,"Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,o):"MultiLineString"===i.type?fo(n,!1,i.coordinates,r,o):"Polygon"===i.type||"MultiPolygon"===i.type?po(n,!1,"Polygon"===i.type?[i.coordinates]:i.coordinates,r,o):null}function mo(e,t,i){const n=[];for(const i of e){const e=[];for(const n of i)e.push(Kr(n,t));n.push(e);}const[r,o]=kr(n[0][0][1]);if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return fo("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n,r,o);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const a=fo(i.coordinates[t],!0,n,r,o,e);if(isNaN(a))return a;if(0===(e=Math.min(e,a)))return e}return e}if("Polygon"===i.type||"MultiPolygon"===i.type){let e=1/0;for(let t=0;t<n.length;t++){const a=po(n[t],!0,"Polygon"===i.type?[i.coordinates]:i.coordinates,r,o,e);if(isNaN(a))return a;if(0===(e=Math.min(e,a)))return e}return e}return null}function go(e,t,i){const n=[];for(const i of Ne(e,0)){const e=[];for(let n=0;n<i.length;++n)e.push(Qr(i[n],t));n.push(e);}const[r,o]=kr(n[0][0][0][1]);if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return po("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n,r,o);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const a=po(i.coordinates[t],!0,n,r,o,e);if(isNaN(a))return a;if(0===(e=Math.min(e,a)))return e}return e}return "Polygon"===i.type||"MultiPolygon"===i.type?function(e,t,i,n){let r=1/0;for(const o of e)for(const e of t){const t=lo(o,e,i,n,r);if(isNaN(t))return t;if(0===(r=Math.min(r,t)))return r}return r}("Polygon"===i.type?[i.coordinates]:i.coordinates,n,r,o):null}function yo(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}function xo(e){if(!Hn(e)||"object"!=typeof e||null===e||Array.isArray(e))return null;const t=e;if("FeatureCollection"===t.type){if(0===t.features.length)return null;const e=[];for(const i of t.features){if(!yo(i.geometry.type))return null;e.push(i.geometry);}return e}return "Feature"===t.type?yo(t.geometry.type)?[t.geometry]:null:yo(t.type)?[t]:null}class vo{constructor(e){this.type=En,this.geojson=e;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);const i=e[1],n=Hn(i)&&!Array.isArray(i),r=t.parse(n?["literal",i]:i,1,Sn);if(!r)return null;for(const[e,i]of [[["measure-light"],"brightness"],[["pitch"],"pitch"],[["distance-from-center"],"distance-from-center"]])if(!Lr(r,e))return t.error(`'distance' expression may not depend on ${i}.`);return Fr(r)?r instanceof Wn&&!xo(r.value)?t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj]."):new vo(r):t.error("'distance' expression may not depend on feature-state.")}evaluate(e){const t=xo(this.geojson.evaluate(e));if(!t)return console.warn("Distance Expression: could not resolve a valid Point/LineString/Polygon GeoJSON geometry."),null;const i=e.geometry(),n=e.canonicalID();if(null==i||null==n)return console.warn("Distance Expression: requires valid feature and canonical information."),null;const r=e.geometryType(),o="Point"===r?_o:"LineString"===r?mo:"Polygon"===r?go:null;if(!o)return console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries."),null;let a=1/0;for(const e of t){const t=o(i,n,e);if(null==t||isNaN(t))return t;if(0===(a=Math.min(a,t)))break}return a}eachChild(e){e(this.geojson);}outputDefined(){return !0}serialize(){return ["distance",this.geojson.serialize()]}}class bo{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 bo(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}serialize(){return ["var",this.name]}}class wo{constructor(e,t=[],i,n=new bn,r=[],o,a,s){this.registry=e,this.path=t,this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=a,this.iconImageUseTheme=s;}get key(){let e="";for(let t=0;t<this.path.length;t++){const i=this.path[t];e+="string"==typeof i?`['${i}']`:`[${i}]`;}return e}parse(e,t,i,n,r={}){if(t||i){const o=this.expectedType,a=this.scope;n&&(this.scope=this.scope.concat(n)),this.expectedType=i||null;const s="number"==typeof t;s&&this.path.push(t);const l=this._parse(e,r);return s&&this.path.pop(),this.expectedType=o,this.scope=a,l}return this._parse(e,r)}parseObjectValue(e,t,i,n,r,o={}){const a=this.expectedType,s=this.scope;r&&(this.scope=this.scope.concat(r)),this.expectedType=n||null,this.path.push(t),this.path.push(i);const l=this._parse(e,o);return this.path.pop(),this.path.pop(),this.expectedType=a,this.scope=s,l}_parse(e,t){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 i="string"==typeof e[0]&&Object.hasOwn(this.registry,e[0])?this.registry[e[0]]:void 0;if(i){let n=i.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,i=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else n=Ao(n,e,t.typeAnnotation||"coerce");else n=Ao(n,e,t.typeAnnotation||"assert");}if(!(n instanceof Wn)&&"resolvedImage"!==n.type.kind&&Io(n)){const e=new sr(this._scope,this.options,this.iconImageUseTheme);try{n=new Wn(n.type,n.evaluate(e));}catch(e){return this.error(e.message),null}}return n}return or.parse(["to-array",e],this)}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,n){const r=n?this.scope.concat(n):this.scope,o=this.path.slice();return "number"==typeof e&&o.push(e),"string"==typeof t&&o.push(t),new wo(this.registry,o,i||null,r,this.errors,this._scope,this.options,this.iconImageUseTheme)}_forkForSignature(){return new wo(this.registry,this.path.slice(),null,this.scope,[],this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new vn(i,e));}checkSubtype(e,t,i){const n=On(e,t);return n&&this.error(n,..."number"==typeof i?[i]:[]),n}}const Eo=new Set(["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"]);function Ao(e,t,i){return "assert"===i?new Yn(t,[e]):"coerce"===i?new or(t,[e]):e}function Io(e){if(e instanceof bo)return Io(e.boundExpression);if(e instanceof lr&&"error"===e.name)return !1;if(e instanceof cr)return !1;if(e instanceof Tr)return !1;if(e instanceof vo)return !1;if(e instanceof Dr)return !1;const t=e instanceof or||e instanceof Yn;let i=!0;return e.eachChild(e=>{i=t?i&&Io(e):i&&e instanceof Wn;}),!!i&&Cr(e)&&Or(e,Eo)}function To(e,t){const i=e.length-1;let n,r,o=0,a=i,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),n=e[s],r=e[s+1],n<=t){if(s===i||t<r)return s;o=s+1;}else {if(!(n>t))throw new qn("Input is not a number.");a=s-1;}return 0}class Mo{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,En);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],a=e[i+1],s=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.',s);if(n.length&&n.at(-1)[0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,r);if(!u)return null;r=r||u.type,n.push([o,u]);}return new Mo(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[To(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const So=.95047,zo=1.08883,Ro=4/29,Po=6/29,Do=3*Po*Po,Co=Po*Po*Po,Fo=Math.PI/180,Oo=180/Math.PI;function Lo(e){return e>Co?Math.pow(e,1/3):e/Do+Ro}function Bo(e){return e>Po?e*e*e:Do*(e-Ro)}function No(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Vo(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ko(e){const t=Vo(e.r),i=Vo(e.g),n=Vo(e.b),r=Lo((.4124564*t+.3575761*i+.1804375*n)/So),o=Lo((.2126729*t+.7151522*i+.072175*n)/1);return {l:116*o-16,a:500*(r-o),b:200*(o-Lo((.0193339*t+.119192*i+.9503041*n)/zo)),alpha:e.a}}function Uo(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Bo(t),i=So*Bo(i),n=zo*Bo(n),new pn(No(3.2404542*i-1.5371385*t-.4985314*n),No(-.969266*i+1.8760108*t+.041556*n),No(.0556434*i-.2040259*t+1.0572252*n),e.alpha)}function Go(e,t,i){const n=t-e;return e+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const jo={forward:ko,reverse:Uo,interpolate:function(e,t,i){return {l:dn(e.l,t.l,i),a:dn(e.a,t.a,i),b:dn(e.b,t.b,i),alpha:dn(e.alpha,t.alpha,i)}}},Ho={forward:function(e){const{l:t,a:i,b:n}=ko(e),r=Math.atan2(n,i)*Oo;return {h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Fo,i=e.c;return Uo({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return {h:Go(e.h,t.h,i),c:dn(e.c,t.c,i),l:dn(e.l,t.l,i),alpha:dn(e.alpha,t.alpha,i)}}};var $o=Object.freeze({__proto__:null,hcl:Ho,lab:jo});class Zo{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=Wo(t,e.base,i,n);else if("linear"===e.name)r=Wo(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=Re(o[0],o[1],o[2],o[3])(Wo(t,1,i,n));}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e};}else {if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(r=t.parse(r,2,En),!r)return null;const a=[];let s=null;"interpolate-hcl"===i||"interpolate-lab"===i?s=Tn:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],n=o[e+1],r=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.',r);if(a.length&&a.at(-1)[0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const u=t.parse(n,l,s);if(!u)return null;s=s||u.type,a.push([i,u]);}return "number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Zo(s,i,n,r,a):t.error(`Type ${Cn(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=To(t,n),a=Zo.interpolationFactor(this.interpolation,n,t[o],t[o+1]),s=i[o].evaluate(e),l=i[o+1].evaluate(e);return "interpolate"===this.operator?xn[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Ho.reverse(Ho.interpolate(Ho.forward(s),Ho.forward(l),a)):jo.reverse(jo.interpolate(jo.forward(s),jo.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Wo(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}class qo{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument."),null;let i=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e);}const o=n&&r.some(e=>On(n,e.type));return new qo(o?Sn:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(e),i&&i instanceof Gn&&!i.available&&(t||(t=i),i=null,n===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize());}),e}}const Xo=/[^a-zA-Z0-9_]/;class Yo{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 n=1;n<e.length-1;n+=2){const r=e[n];if("string"!=typeof r)return t.error(`Expected string, but found ${typeof r} instead.`,n);if(Xo.test(r))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const o=t.parse(e[n+1],n+1);if(!o)return null;i.push([r,o]);}const n=t.parse(e.at(-1),e.length-1,t.expectedType,i);return n?new Yo(i,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}class Jo{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,En),n=t.parse(e[2],2,Dn(t.expectedType||Sn));return i&&n?new Jo(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new qn("Array index out of bounds: negative index");if(t>=i.length)throw new qn("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new qn("Array index must be an integer. Use at-interpolated for fractional indices");return i[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class Ko{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,En),n=t.parse(e[2],2,Dn(t.expectedType||Sn));return i&&n?new Ko(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new qn(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new qn(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t===Math.floor(t))return i[t];const n=Math.floor(t),r=Math.ceil(t),o=i[n],a=i[r];if("number"!=typeof o||"number"!=typeof a)throw new qn(`Cannot interpolate between non-number values at index ${t}.`);return dn(o,a,t-n)}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Qo{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let a=2;a<e.length-1;a+=2){let s=e[a];const l=e[a+1];if(Array.isArray(s)||(s=[s]),0===s.length)return t.error("Expected at least one branch label.",a);for(const e of s){if("number"!=typeof e&&"string"!=typeof e)return t.error("Branch labels must be numbers or strings.",a);if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return t.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`,a);if("number"==typeof e&&Math.floor(e)!==e)return t.error("Numeric branch labels must be integer values.",a);if(i){if(t.checkSubtype(i,$n(e),a))return null}else i=$n(e);if(void 0!==r[String(e)])return t.error("Branch labels must be unique.",a);r[String(e)]=o.length;}const u=t.parse(l,a,n);if(!u)return null;n=n||u.type,o.push(u);}const a=t.parse(e[1],1,Sn);if(!a)return null;const s=t.parse(e.at(-1),e.length-1,n);return s?"value"!==a.type.kind&&t.checkSubtype(i,a.type,1)?null:new Qo(i,n,a,r,o,s):null}evaluate(e){const t=this.input.evaluate(e);return (Bn($n(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()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e);}const r=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of i)e.push(1===n.length?r(n[0]):n.map(r)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class ea{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}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;r<e.length-1;r+=2){const o=t.parse(e[r],r,In);if(!o)return null;const a=t.parse(e[r+1],r+1,i);if(!a)return null;n.push([o,a]),i=i||a.type;}const r=t.parse(e.at(-1),e.length-1,i);return r?new ea(i,n,r):null}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()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class ta{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const i=t.parse(e[1],1,Sn),n=t.parse(e[2],2,En);if(!i||!n)return null;if(r=i.type,![Dn(Sn),An,Sn].some(e=>e.kind===r.kind))return t.error(`Expected first argument to be of type array or string, but found ${Cn(i.type)} instead`),null;var r;if(4===e.length){const r=t.parse(e[3],3,En);return r?new ta(i.type,i,n,r):null}return new ta(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Ln(t,["string","array"]))throw new qn(`Expected first argument to be of type array or string, but found ${Cn($n(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(i,n)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ia(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 na(e,t,i,n){return 0===n.compare(t,i)}function ra(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=In,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,Sn);if(!o)return null;if(!ia(i,o.type))return t.error(`"${i}" comparisons are not supported for type '${Cn(o.type)}'.`,1);let a=t.parse(e[2],2,Sn);if(!a)return null;if(!ia(i,a.type))return t.error(`"${i}" comparisons are not supported for type '${Cn(a.type)}'.`,2);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${Cn(o.type)}' and '${Cn(a.type)}'.`);n&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Yn(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Yn(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,zn),!s)return null}return new r(o,a,s)}evaluate(r){const o=this.lhs.evaluate(r),a=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=$n(o),i=$n(a);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new qn(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=$n(o),i=$n(a);if("string"!==e.kind||"string"!==i.kind)return t(r,o,a)}return this.collator?i(r,o,a,this.collator.evaluate(r)):t(r,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize());}),t}}}const oa=ra("==",function(e,t,i){return t===i},na),aa=ra("!=",function(e,t,i){return t!==i},function(e,t,i,n){return !na(0,t,i,n)}),sa=ra("<",function(e,t,i){return t<i},function(e,t,i,n){return n.compare(t,i)<0}),la=ra(">",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),ua=ra("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),ca=ra(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class ha{constructor(e,t,i,n,r,o){this.type=An,this.number=e,this.locale=t,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,En);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parseObjectValue(n.locale,2,"locale",An),!r))return null;let o=null;if(n.currency&&(o=t.parseObjectValue(n.currency,2,"currency",An),!o))return null;let a=null;if(n.unit&&(a=t.parseObjectValue(n.unit,2,"unit",An),!a))return null;let s=null;if(void 0!==n["min-fraction-digits"]&&(s=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",En),!s))return null;let l=null;return void 0===n["max-fraction-digits"]||(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",En),l)?new ha(i,r,o,a,s,l):null}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}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class da{constructor(e){this.type=En,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;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 ${Cn(i.type)} instead.`),null):new da(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 qn(`Expected value to be of type string or array, but found ${Cn($n(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize());}),e}}function fa(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const pa={"==":oa,"!=":aa,">":la,"<":sa,">=":ca,"<=":ua,array:Yn,at:Jo,"at-interpolated":Ko,boolean:Yn,case:ea,coalesce:qo,collator:cr,format:Jn,image:Kn,interpolate:Zo,"interpolate-hcl":Zo,"interpolate-lab":Zo,length:da,let:Yo,literal:Wn,match:Qo,number:Yn,"number-format":ha,object:Yn,slice:ta,step:Mo,string:Yn,"to-boolean":or,"to-color":or,"to-number":or,"to-string":or,var:bo,within:Tr,distance:vo,config:Dr};function _a(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,a=jn(t,i,n,o);if(a)throw new qn(a);return new pn(t/255,i/255,n/255,o)}function ma(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,a=function(e,t,i,n){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,n,o);if(a)throw new qn(a);const s=`hsla(${t}, ${i}%, ${n}%, ${o})`,l=pn.parse(s);if(!l)throw new qn(`Failed to parse HSLA color: ${s}`);return l}function ga(e,t){return e in t}function ya(e,t){const i=t[e];return void 0===i?null:i}function xa(e){return {type:e}}function va(e,t){if(!Ln(e,["boolean","string","number","null"]))throw new qn(`Expected first argument to be of type boolean, string, number or null, but found ${Cn($n(e))} instead.`);if(!Ln(t,["string","array"]))throw new qn(`Expected second argument to be of type array or string, but found ${Cn($n(t))} instead.`)}function ba(e){if(e instanceof Dr)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...ba(e)]);}),t}function wa(e){if(e instanceof lr&&"is-active-floor"===e.name)return !0;let t=!1;return e.eachChild(e=>{!t&&wa(e)&&(t=!0);}),t}function Ea(e){return {result:"success",value:e}}function Aa(e){return {result:"error",value:e}}function Ia(e,t){return !!e&&!!e.parameters&&e.parameters.includes(t)}function Ta(e){return "data-driven"===e["property-type"]}function Ma(e){return Ia(e.expression,"measure-light")}function Sa(e){return Ia(e.expression,"zoom")}function za(e){return !!e.expression&&e.expression.interpolated}function Ra(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function Pa(e){return e}function Da(e,t){const i="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],r=n||!(n||void 0!==e.property),o=e.type||(za(t)?"exponential":"interval");if(i&&((e={...e}).stops&&(e.stops=e.stops.map(e=>[e[0],pn.parse(e[1])])),e.default=pn.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!$o[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,s,l;if("exponential"===o)a=La;else if("interval"===o)a=Oa;else if("categorical"===o){a=Fa,s=Object.create(null);for(const t of e.stops)s[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Ba;}if(n){const i={},n=[];for(let t=0;t<e.stops.length;t++){const r=e.stops[t],o=r[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},n.push(o)),i[o].stops.push([r[0].value,r[1]]);}const r=[];for(const e of n)r.push([i[e].zoom,Da(i[e],t)]);const o={name:"linear"};return {kind:"composite",interpolationType:o,interpolationFactor:Zo.interpolationFactor.bind(void 0,o),zoomStops:r.map(e=>e[0]),evaluate:({zoom:i},n)=>La({stops:r,base:e.base},t,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:i,interpolationFactor:Zo.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,s,l)}}return {kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Ca(e.default,t.default):a(e,t,r,s,l)}}}function Ca(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Fa(e,t,i,n,r){return Ca(typeof i===r?n[i]:void 0,e.default,t.default)}function Oa(e,t,i){if(!ir(i))return Ca(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 r=To(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function La(e,t,i){const n=void 0!==e.base?e.base:1;if(!ir(i))return Ca(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 o=To(e.stops.map(e=>e[0]),i),a=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let u=xn[t.type]||Pa;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=$o[e.colorSpace];u=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),a));}return "function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return u(t,i,a)}}:u(s,l,a)}function Ba(e,t,i){return "color"===t.type?i=pn.parse(i):"formatted"===t.type?i=kn.fromString(i.toString()):"resolvedImage"===t.type?i=Gn.build(i.toString()):Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Ca(i,e.default,t.default)}lr.register(pa,{error:[{kind:"error"},[An],(e,[t])=>{throw new qn(t.evaluate(e))}],typeof:[An,[Sn],(e,[t])=>Cn($n(t.evaluate(e)))],"to-rgba":[Dn(En,4),[Tn],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Dn(En,4),[Tn],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Tn,[En,En,En],_a],rgba:[Tn,[En,En,En,En],_a],hsl:[Tn,[En,En,En],ma],hsla:[Tn,[En,En,En,En],ma],has:{type:In,overloads:[[[An],(e,[t])=>ga(t.evaluate(e),e.properties())],[[An,Mn],(e,[t,i])=>ga(t.evaluate(e),i.evaluate(e))]]},get:{type:Sn,overloads:[[[An],(e,[t])=>ya(t.evaluate(e),e.properties())],[[An,Mn],(e,[t,i])=>ya(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Sn,[An],(e,[t])=>ya(t.evaluate(e),e.featureState||{})],properties:[Mn,[],e=>e.properties()],"geometry-type":[An,[],e=>e.geometryType()],worldview:[An,[],e=>e.globals.worldview||""],"is-active-floor":[In,xa(An),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return !1;if(0===t.length)return !0;const i=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return i.has(n)})}],id:[Sn,[],e=>e.id()],zoom:[En,[],e=>e.globals.zoom],pitch:[En,[],e=>e.globals.pitch||0],"distance-from-center":[En,[],e=>e.distanceFromCenter()],"measure-light":[En,[An],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[En,[],e=>e.globals.heatmapDensity||0],"line-progress":[En,[],e=>e.globals.lineProgress||0],"raster-value":[En,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[En,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[En,[],e=>e.globals.skyRadialProgress||0],accumulated:[Sn,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[En,xa(En),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[En,xa(En),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:En,overloads:[[[En,En],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[En],(e,[t])=>-t.evaluate(e)]]},"/":[En,[En,En],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[En,[En,En],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[En,[],()=>Math.LN2],pi:[En,[],()=>Math.PI],e:[En,[],()=>Math.E],"^":[En,[En,En],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[En,[En],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[En,[En],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[En,[En],(e,[t])=>Math.log(t.evaluate(e))],log2:[En,[En],(e,[t])=>Math.log2(t.evaluate(e))],sin:[En,[En],(e,[t])=>Math.sin(t.evaluate(e))],cos:[En,[En],(e,[t])=>Math.cos(t.evaluate(e))],tan:[En,[En],(e,[t])=>Math.tan(t.evaluate(e))],asin:[En,[En],(e,[t])=>Math.asin(t.evaluate(e))],acos:[En,[En],(e,[t])=>Math.acos(t.evaluate(e))],atan:[En,[En],(e,[t])=>Math.atan(t.evaluate(e))],min:[En,xa(En),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[En,xa(En),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[En,[En],(e,[t])=>Math.abs(t.evaluate(e))],round:[En,[En],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[En,[En],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[En,[En],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[In,[An,Sn],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[In,[Sn],(e,[t])=>e.id()===t.value],"filter-type-==":[In,[An],(e,[t])=>e.geometryType()===t.value],"filter-<":[In,[An,Sn],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<r}],"filter-id-<":[In,[Sn],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<n}],"filter->":[In,[An,Sn],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[In,[Sn],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[In,[An,Sn],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[In,[Sn],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[In,[An,Sn],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[In,[Sn],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[In,[Sn],(e,[t])=>t.value in e.properties()],"filter-has-id":[In,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[In,[Dn(An)],(e,[t])=>t.value.includes(e.geometryType())],"filter-id-in":[In,[Dn(Sn)],(e,[t])=>t.value.includes(e.id())],"filter-in-small":[In,[An,Dn(Sn)],(e,[t,i])=>i.value.includes(e.properties()[t.value])],"filter-in-large":[In,[An,Dn(Sn)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return !0;t[r]>e?n=r-1:i=r+1;}return !1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:In,overloads:[[[In,In],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[xa(In),(e,t)=>{for(const i of t)if(!i.evaluate(e))return !1;return !0}]]},any:{type:In,overloads:[[[In,In],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[xa(In),(e,t)=>{for(const i of t)if(i.evaluate(e))return !0;return !1}]]},"!":[In,[In],(e,[t])=>!t.evaluate(e)],"is-supported-script":[In,[An],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return !i||i(t.evaluate(e))}],upcase:[An,[An],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[An,[An],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[An,xa(Sn),(e,t)=>t.map(t=>Zn(t.evaluate(e))).join("")],split:[Dn(An),[An,An],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],in:[In,[Sn,Sn],(e,[t,i])=>{const n=t.evaluate(e),r=i.evaluate(e);return null!=r&&(va(n,r),r.includes(n))}],"index-of":{type:En,overloads:[[[Sn,Sn],(e,[t,i])=>{const n=t.evaluate(e),r=i.evaluate(e);return va(n,r),r.indexOf(n)}],[[Sn,Sn,En],(e,[t,i,n])=>{const r=t.evaluate(e),o=i.evaluate(e),a=n.evaluate(e);return va(r,o),o.indexOf(r,a)}]]},"resolved-locale":[An,[zn],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[En,[En,En,Sn],(e,t)=>{const[i,n,r]=t.map(t=>t.evaluate(e));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return t}(r);else {if("number"!=typeof r)throw new qn(`Invalid seed input: ${r}`);o=r;}return i+fa(o)()*(n-i)}]});class Na{constructor(e,t,i,n,r){this.expression=e,this._warningHistory={},this._scope=i,this._options=n,this._iconImageUseTheme=r,this._evaluator=new sr(i,n,r),this._defaultValue=t?function(e){return "color"===e.type&&(Ra(e.default)||Array.isArray(e.default))?new pn(0,0,0,0):"color"===e.type?pn.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this.configDependencies=ba(e),this.isIndoorDependent=wa(e);}evaluateWithoutErrorHandling(e,t,i,n,r,o,a,s){const l=this._evaluator;return l.globals=e,l.feature=t,l.featureState=i,l.canonical=n||null,l.availableImages=r||null,l.formattedSection=o,l.featureTileCoord=a||null,l.featureDistanceData=s||null,this.expression.evaluate(l)}evaluate(e,t,i,n,r,o,a,s,l){this._evaluator||(this._evaluator=new sr(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this._evaluator.iconImageUseTheme=l||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 qn(`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){const t=e;return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Va(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&Object.hasOwn(pa,e[0])}function ka(e,t,i,n,r){const o=new wo(pa,[],t?function(e){const t={color:Tn,string:An,number:En,enum:An,boolean:In,formatted:Rn,resolvedImage:Pn,object:Mn};return "array"===e.type?Dn(t[e.value]||Sn,e.length):t[e.type]}(t):void 0,void 0,void 0,i,n,r),a=o.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?Ea(new Na(a,t,i,n,r)):Aa(o.errors)}class Ua{constructor(e,t,i,n){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!Fr(t.expression),this.configDependencies=ba(t.expression),this.isIndoorDependent=wa(t.expression);}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o,a){return this._styleExpression.evaluate(e,t,i,n,r,o,void 0,void 0,a)}}class Ga{constructor(e,t,i,n,r,o){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Fr(t.expression),this.isIndoorDependent=wa(t.expression),this.isLightConstant=r,this.isLineProgressConstant=o,this.configDependencies=ba(t.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?Zo.interpolationFactor(this.interpolationType,e,t,i):0}}function ja(e,t,i,n,r){if("error"===(e=ka(e,t,i,n,r)).result)return e;const o=e.value.expression,a=Cr(o);if(!a&&!Ta(t))return Aa([new vn("","data expressions not supported")]);const s=Lr(o,["zoom","pitch","distance-from-center"]);if(!s&&!Sa(t))return Aa([new vn("","zoom expressions not supported")]);const l=Lr(o,["measure-light"]);if(!l&&!Ma(t))return Aa([new vn("","measure-light expression not supported")]);const u=Lr(o,["line-progress"]);if(!u&&!function(e){return Ia(e.expression,"line-progress")}(t))return Aa([new vn("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=$a(o);return h||s||c?h instanceof vn?Aa([h]):h instanceof Zo&&!za(t)?Aa([new vn("",'"interpolate" expressions cannot be used with this property')]):Ea(h?new Ga(a&&u?"camera":"composite",e.value,h.labels,h instanceof Zo?h.interpolation:void 0,l,u):new Ua(a&&u?"constant":"source",e.value,l,u)):Aa([new vn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Ha{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,Da(this._parameters,this._specification));}static deserialize(e){return new Ha(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function $a(e){let t=null;if(e instanceof Yo)t=$a(e.result);else if(e instanceof qo){for(const i of e.args)if(t=$a(i),t)break}else (e instanceof Mo||e instanceof Zo)&&e.input instanceof lr&&"zoom"===e.input.name&&(t=e);return t instanceof vn||e.eachChild(e=>{const i=$a(e);i instanceof vn?t=i:t&&i&&t!==i&&(t=new vn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));}),t}class Za{constructor(e,t,i){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const t=new Int32Array(e);this.width=t[0],this.height=t[1],this.xCellCount=t[2],this.yCellCount=t[3],this.boxUid=t[4],this.circleUid=t[5];const i=this.xCellCount*this.yCellCount,n=[];for(let e=0;e<i;e++){const i=t[6+e],r=t[6+e+1];n.push(i===r?null:t.subarray(i,r));}const r=t[6+i],o=[];for(let e=0;e<i;e++){const i=t[r+e],n=t[r+e+1];o.push(i===n?null:t.subarray(i,n));}let a=t[r+i];this.boxCells=n,this.circleCells=o,this.boxKeys=t.subarray(a,a+this.boxUid),a+=this.boxUid,this.circleKeys=t.subarray(a,a+this.circleUid),a+=this.circleUid,this.bboxes=t.subarray(a,a+4*this.boxUid),a+=4*this.boxUid,this.circles=t.subarray(a,a+3*this.circleUid);}else {this.width=e,this.height=t,this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);const n=this.xCellCount*this.yCellCount,r=[],o=[];for(let e=0;e<n;e++)r.push([]),o.push([]);this.boxCells=r,this.circleCells=o,this.boxKeys=[],this.circleKeys=[],this.bboxes=[],this.circles=[],this.boxUid=0,this.circleUid=0;}this.xScale=this.xCellCount/this.width,this.yScale=this.yCellCount/this.height;}keysLength(){return this.boxKeys.length+this.circleKeys.length}clear(){for(const e of this.boxCells)e&&(e.length=0);for(const e of this.circleCells)e&&(e.length=0);this.circleKeys.length=0,this.boxKeys.length=0,this.bboxes.length=0,this.circles.length=0,this.boxUid=0,this.circleUid=0;}insert(e,t,i,n,r){const o=this.boxUid++,a=this._xCell(t),s=this._yCell(i),l=this._xCell(n),u=this._yCell(r);for(let e=a;e<=l;e++)for(let t=s;t<=u;t++)this.boxCells[this.xCellCount*t+e].push(o);this.boxKeys.push(e),this.bboxes.push(t,i,n,r);}insertCircle(e,t,i,n){const r=this.circleUid++,o=this._xCell(t-n),a=this._yCell(i-n),s=this._xCell(t+n),l=this._yCell(i+n);for(let e=o;e<=s;e++)for(let t=a;t<=l;t++)this.circleCells[this.xCellCount*t+e].push(r);this.circleKeys.push(e),this.circles.push(t,i,n);}query(e,t,i,n,r){const o=[];if(i<0||e>this.width||n<0||t>this.height)return o;const a=this._nextGen(),{boxCells:s,circleCells:l,boxKeys:u,circleKeys:c,bboxes:h,circles:d,boxSeen:f,circleSeen:p,xCellCount:_}=this,m=this._xCell(e),g=this._yCell(t),y=this._xCell(i),x=this._yCell(n);for(let v=m;v<=y;v++)for(let m=g;m<=x;m++){const g=_*m+v,y=s[g];if(y)for(let s=0;s<y.length;s++){const l=y[s];if(f[l]===a)continue;f[l]=a;const c=4*l,d=h[c],p=h[c+1],_=h[c+2],m=h[c+3];e<=_&&t<=m&&i>=d&&n>=p&&(!r||r(u[l]))&&o.push({key:u[l],x1:d,y1:p,x2:_,y2:m});}const x=l[g];if(x)for(let s=0;s<x.length;s++){const l=x[s];if(p[l]===a)continue;p[l]=a;const u=3*l,h=d[u],f=d[u+1],_=d[u+2];!this._circleAndRectCollide(h,f,_,e,t,i,n)||r&&!r(c[l])||o.push({key:c[l],x1:h-_,y1:f-_,x2:h+_,y2:f+_});}}return o}queryKeys(e,t,i,n,r){const o=[];if(i<0||e>this.width||n<0||t>this.height)return o;const a=this._nextGen(),{boxCells:s,boxKeys:l,bboxes:u,boxSeen:c,xCellCount:h,xScale:d,yScale:f}=this,p=this._xCell(e),_=this._yCell(t),m=this._xCell(i),g=this._yCell(n);for(let y=p;y<=m;y++)for(let p=_;p<=g;p++){if(r&&!r(y/d,p/f,(y+1)/d,(p+1)/f))continue;const _=s[h*p+y];if(_)for(let s=0;s<_.length;s++){const h=_[s];if(c[h]===a)continue;c[h]=a;const d=4*h,f=u[d],p=u[d+1],m=u[d+2],g=u[d+3];(r?r(f,p,m,g):e<=m&&t<=g&&i>=f&&n>=p)&&o.push(l[h]);}}return o}hitTest(e,t,i,n,r){if(i<0||e>this.width||n<0||t>this.height)return !1;const o=this._nextGen(),{boxCells:a,circleCells:s,boxKeys:l,circleKeys:u,bboxes:c,circles:h,boxSeen:d,circleSeen:f,xCellCount:p}=this,_=this._xCell(e),m=this._yCell(t),g=this._xCell(i),y=this._yCell(n);for(let x=_;x<=g;x++)for(let _=m;_<=y;_++){const m=p*_+x,g=a[m];if(g)for(let a=0;a<g.length;a++){const s=g[a];if(d[s]===o)continue;d[s]=o;const u=4*s;if(e<=c[u+2]&&t<=c[u+3]&&i>=c[u]&&n>=c[u+1]&&(!r||r(l[s])))return !0}const y=s[m];if(y)for(let a=0;a<y.length;a++){const s=y[a];if(f[s]===o)continue;f[s]=o;const l=3*s;if(this._circleAndRectCollide(h[l],h[l+1],h[l+2],e,t,i,n)&&(!r||r(u[s])))return !0}}return !1}hitTestCircle(e,t,i,n){const r=e-i,o=t-i,a=e+i,s=t+i;if(a<0||r>this.width||s<0||o>this.height)return !1;const l=this._nextGen(),{boxCells:u,circleCells:c,boxKeys:h,circleKeys:d,bboxes:f,circles:p,boxSeen:_,circleSeen:m,xCellCount:g}=this,y=this._xCell(r),x=this._yCell(o),v=this._xCell(a),b=this._yCell(s);for(let r=y;r<=v;r++)for(let o=x;o<=b;o++){const a=g*o+r,s=u[a];if(s)for(let r=0;r<s.length;r++){const o=s[r];if(_[o]===l)continue;_[o]=l;const a=4*o;if(this._circleAndRectCollide(e,t,i,f[a],f[a+1],f[a+2],f[a+3])&&(!n||n(h[o])))return !0}const y=c[a];if(y)for(let r=0;r<y.length;r++){const o=y[r];if(m[o]===l)continue;m[o]=l;const a=3*o;if(this._circlesCollide(p[a],p[a+1],p[a+2],e,t,i)&&(!n||n(d[o])))return !0}}return !1}static serialize(e,t){const i=e.toArrayBuffer();return t&&t.add(i),{buffer:i}}static deserialize(e){return new Za(e.buffer)}toArrayBuffer(){const e=this.xCellCount*this.yCellCount;let t=0,i=0;for(let n=0;n<e;n++)t+=this.boxCells[n].length,i+=this.circleCells[n].length;const n=new Int32Array(6+(e+1)+t+(e+1)+i+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);n[0]=this.width,n[1]=this.height,n[2]=this.xCellCount,n[3]=this.yCellCount,n[4]=this.boxUid,n[5]=this.circleUid;let r=6+(e+1);for(let t=0;t<e;t++){n[6+t]=r;const e=this.boxCells[t];n.set(e,r),r+=e.length;}n[6+e]=r;const o=r;r+=e+1;for(let t=0;t<e;t++){n[o+t]=r;const e=this.circleCells[t];n.set(e,r),r+=e.length;}return n[o+e]=r,n.set(this.boxKeys,r),r+=this.boxUid,n.set(this.circleKeys,r),r+=this.circleUid,n.set(this.bboxes,r),r+=4*this.boxUid,n.set(this.circles,r),n.buffer}_xCell(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_yCell(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_nextGen(){return this.boxSeen.length<this.boxUid&&(this.boxSeen=new Uint32Array(this.boxUid)),this.circleSeen.length<this.circleUid&&(this.circleSeen=new Uint32Array(this.circleUid)),this.generation=this.generation+1>>>0,0===this.generation&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}_circlesCollide(e,t,i,n,r,o){const a=n-e,s=r-t,l=i+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,i,n,r,o,a){const s=(o-n)/2,l=Math.abs(e-(n+s));if(l>s+i)return !1;const u=(a-r)/2,c=Math.abs(t-(r+u));if(c>u+i)return !1;if(l<=s||c<=u)return !0;const h=l-s,d=c-u;return h*h+d*d<=i*i}}const Wa={};function qa(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),Wa[t]={klass:e,omit:i.omit||[]};}qa(Object,"Object"),qa(Za,"Grid"),delete Pe.prototype.constructor,qa(pn,"Color"),qa(kn,"Formatted"),qa(Vn,"FormattedSection"),qa(Gn,"ResolvedImage"),qa(Ha,"StylePropertyFunction"),qa(Na,"StyleExpression",{omit:["_evaluator"]}),qa(ln,"ImageId"),qa(Un,"ImageVariant"),qa(Ga,"ZoomDependentExpression"),qa(Ua,"ZoomConstantExpression"),qa(lr,"CompoundExpression",{omit:["_evaluate"]});for(const e in pa)Wa[pa[e]._classRegistryKey]||qa(pa[e],`Expression${e}`);function Xa(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}const Ya={Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError},Ja=new Set(["message","stack","cause","errors","name","class"]);function Ka(e,t){if(null===e)return null;const i=typeof e;if("object"!==i)return "bigint"===i?{$name:"BigInt",value:e.toString()}:e;if(Array.isArray(e)){const i=e.length,n=[];n.length=i;for(let r=0;r<i;r++)n[r]=Ka(e[r],t);return n}if(ArrayBuffer.isView(e))return t&&t.add(e.buffer),e;if(Xa(e)||e instanceof ImageBitmap)return t&&t.add(e),e;if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(e instanceof Map){const i={$name:"Map",entries:[]};for(const[n,r]of e.entries())i.entries.push(Ka(n),Ka(r,t));return i}if(e instanceof Headers)return {$name:"Headers",entries:[...e]};if(e instanceof Set){const t={$name:"Set"};let i=0;for(const n of e.values())t[++i]=Ka(n);return t}if(e instanceof Date||e instanceof RegExp||e instanceof Boolean||e instanceof Number||e instanceof String)return e;if(e instanceof Error){const i=e,n=i.constructor&&i.constructor.name||"Error",r={$name:"$Error",class:i instanceof si?"AJAXError":i instanceof DOMException?"DOMException":i instanceof AggregateError?"AggregateError":Ya[n]?n:"Error",name:i.name,message:i.message};i.stack&&(r.stack=i.stack),"cause"in i&&i.cause!==i&&(r.cause=Ka(i.cause,t)),i instanceof AggregateError&&(r.errors=i.errors.filter(e=>e!==i).map(e=>Ka(e,t)));const o=i;for(const e in o)Object.hasOwn(o,e)&&(Ja.has(e)||(r[e]=Ka(o[e],t)));return r}const n=e.constructor||Object,r=n._classRegistryKey;if(!r)throw new Error(`Can't serialize object of unregistered class "${n.name}".`);const o=n.serialize?n.serialize(e,t):{};if(!n.serialize){const i=Wa[r].omit,n=e;for(const e in n)Object.hasOwn(n,e)&&(i.includes(e)||(o[e]=Ka(n[e],t)));}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(o.$name=r),o}function Qa(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e)){for(let t=0;t<e.length;t++)e[t]=Qa(e[t]);return e}if(ArrayBuffer.isView(e)||Xa(e)||e instanceof ImageBitmap||e instanceof ImageData||e instanceof Date||e instanceof RegExp||e instanceof Boolean||e instanceof Number||e instanceof String)return e;const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],i=new Map;for(let e=0;e<t.length;e+=2)i.set(Qa(t[e]),Qa(t[e+1]));return i}if("Headers"===t)return new Headers(e.entries);if("Set"===t){const t=new Set;for(const i in e)"$name"!==i&&t.add(Qa(e[i]));return t}if("BigInt"===t)return BigInt(e.value);if("$Error"===t){const t=e.class||"Error",i=e.name||t,n=e.message||"";let r;r="DOMException"===t?new DOMException(n,i):"AggregateError"===t?new AggregateError((e.errors||[]).map(Qa),n):"AJAXError"===t?new si(e.statusText,e.status,e.url):new(Ya[t]||Error)(n),"DOMException"!==t&&(r.name=i),e.stack&&(r.stack=e.stack),"cause"in e&&(r.cause=Qa(e.cause));const o=r;for(const t in e)Object.hasOwn(e,t)&&("$name"===t||Ja.has(t)||(o[t]=Qa(e[t])));return r}const{klass:i}=Wa[t];if(!i)throw new Error(`Can't deserialize unregistered class "${t}".`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const t in e)"$name"!==t&&(n[t]=Qa(e[t]));return n}const es=e=>e>=1536&&e<=1791,ts=e=>e>=1872&&e<=1919,is=e=>e>=2208&&e<=2303,ns=e=>e>=11904&&e<=12031,rs=e=>e>=12032&&e<=12255,os=e=>e>=12272&&e<=12287,as=e=>e>=12288&&e<=12351,ss=e=>e>=12352&&e<=12447,ls=e=>e>=12448&&e<=12543,us=e=>e>=12544&&e<=12591,cs=e=>e>=12704&&e<=12735,hs=e=>e>=12736&&e<=12783,ds=e=>e>=12784&&e<=12799,fs=e=>e>=12800&&e<=13055,ps=e=>e>=13056&&e<=13311,_s=e=>e>=13312&&e<=19903,ms=e=>e>=19968&&e<=40959,gs=e=>e>=40960&&e<=42127,ys=e=>e>=42128&&e<=42191,xs=e=>e>=44032&&e<=55215,vs=e=>e>=63744&&e<=64255,bs=e=>e>=64336&&e<=65023,ws=e=>e>=65040&&e<=65055,Es=e=>e>=65072&&e<=65103,As=e=>e>=65104&&e<=65135,Is=e=>e>=65136&&e<=65279,Ts=e=>e>=65280&&e<=65519;function Ms(e){for(const t of e)if(zs(t.charCodeAt(0)))return !0;return !1}function Ss(e){return !(es(e)||ts(e)||is(e)||bs(e)||Is(e))}function zs(e){return !(746!==e&&747!==e&&(e<4352||!(cs(e)||us(e)||Es(e)&&!(e>=65097&&e<=65103)||vs(e)||ps(e)||ns(e)||hs(e)||!(!as(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||_s(e)||ms(e)||fs(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||xs(e)||ss(e)||os(e)||(e=>e>=12688&&e<=12703)(e)||rs(e)||ds(e)||ls(e)&&12540!==e||!(!Ts(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!As(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||ws(e)||(e=>e>=19904&&e<=19967)(e)||gs(e)||ys(e))))}function Rs(e){return !(zs(e)||function(e){return !!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||as(e)||ls(e)||(e=>e>=57344&&e<=63743)(e)||Es(e)||As(e)||Ts(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Ps(e){return e>=1424&&e<=2303||bs(e)||Is(e)}function Ds(e,t){return !(!t&&Ps(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Cs(e){for(const t of e)if(Ps(t.charCodeAt(0)))return !0;return !1}const Fs={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Os=null,Ls=Fs.unavailable,Bs=null;const Ns=function(e){e&&(Ls=Fs.error),Os&&Os(e);};function Vs(){ks.fire(new nn("pluginStateChange",{pluginStatus:Ls,pluginURL:Bs}));}const ks=new sn,Us=function(){return Ls},Gs=function(){if(Ls!==Fs.deferred||!Bs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ls=Fs.loading,Vs(),Bs&&_i({url:Bs}).then(()=>{Ls=Fs.loaded,Vs();}).catch(e=>{Ns(e);});},js={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ls===Fs.loaded||null!=js.applyArabicShaping,isLoading:()=>Ls===Fs.loading,setState(e){Ls=e.pluginStatus,Bs=e.pluginURL;},isParsing:()=>Ls===Fs.parsing,isParsed:()=>Ls===Fs.parsed,getPluginURL:()=>Bs};class Hs{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const i of e)if(!Ds(i.charCodeAt(0),t))return !1;return !0}(e,js.isLoaded())}}class $s{constructor(e,t,i,n,r){this.property=e,this.value=t,this.expression=function(e,t,i,n,r){if(Ra(e))return new Ha(e,t);if(Va(e)||Array.isArray(e)&&e.length>0){const o=ja(e,t,i,n,r);if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));return o.value}{let i=e;return "string"==typeof e&&"color"===t.type&&(i=pn.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i,n,r);}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i,n){return this.property.possiblyEvaluate(this,e,t,i,n)}}class Zs{constructor(e,t,i,n){this.property=e,this.value=new $s(e,void 0,t,i,n);}transitioned(e,t){return new qs(this.property,this.value,t,{...e.transition,...this.transition},e.now)}untransitioned(){return new qs(this.property,this.value,null,{},0)}}class Ws{constructor(e,t,i,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return ft(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Zs(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new $s(this._values[e].property,null===t?void 0:ft(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent());}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,n);}else Object.hasOwn(i,t)&&this.setValue(t,n);}}getTransition(e){return ft(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Zs(this._values[e].property)),this._values[e].transition=ft(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 n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n);}return e}transitioned(e,t){const i=new Xs(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Xs(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class qs{constructor(e,t,i,n,r){const o=n.delay||0,a=n.duration||0;r=r||0,this.property=e,this.value=t,this.begin=r+o,this.end=this.begin+a,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i);}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n<this.begin)return o.possiblyEvaluate(e,t,i);{const a=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),r,Qe(a))}}return r}}class Xs{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues);}possiblyEvaluate(e,t,i){const n=new Ks(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return !0;return !1}}class Ys{constructor(e,t,i,n){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return ft(this._values[e].value)}setValue(e,t){this._values[e]=new $s(this._values[e].property,null===t?void 0:ft(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent());}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,n){const r=new Ks(this._properties);for(const o of Object.keys(this._values))r._values[o]=this._values[o].possiblyEvaluate(e,t,i,n);return r}isIndoorDependent(){return this._isIndoorDependent}}class Js{constructor(e,t,i,n){this.property=e,this.value=t,this.parameters=i,this.iconImageUseTheme=n;}isConstant(){return "constant"===this.value.kind}constantOr(e){return "constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,n,r){return this.property.evaluate(this.value,this.parameters,e,t,i,n,this.iconImageUseTheme,r)}}class Ks{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues);}get(e){return this._values[e]}}class Qs{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const n=xn[this.specification.type];return n?n(e,t,i):e}}class el{constructor(e,t){this.specification=e,this.overrides=t;}possiblyEvaluate(e,t,i,n,r){return "constant"===e.expression.kind||"camera"===e.expression.kind?new Js(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,n,void 0,r)},t):new Js(this,e.expression,t,r)}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 n=xn[this.specification.type];return n?new Js(this,{kind:"constant",value:n(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,n,r,o,a,s){return "constant"===e.kind?e.value:e.evaluate(t,i,n,r,o,s,a)}}class tl{constructor(e){this.specification=e;}possiblyEvaluate(e,t,i,n){return !!e.expression.evaluate(t,null,{},i,n)}interpolate(){return !1}}class il{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Hs(0,{});for(const i in e){const n=e[i],r=n.specification;r&&r.overridable&&this.overridableProperties.push(i);const o=this.defaultPropertyValues[i]=new $s(n,void 0),a=this.defaultTransitionablePropertyValues[i]=new Zs(n);this.defaultTransitioningPropertyValues[i]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate(t);}}}qa(el,"DataDrivenProperty"),qa(Qs,"DataConstantProperty"),qa(tl,"ColorRampProperty");var nl=JSON.parse('{"expression":1,"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":1,"parameters":["distance-from-center","feature","feature-state","measure-light","pitch","zoom"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"function":{"type":{"type":"enum","default":"exponential","values":{"identity":1,"exponential":1,"interval":1,"categorical":1}},"default":{"type":"*"},"expression":1,"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"colorSpace":{"type":"enum","default":"rgb","values":{"rgb":1,"lab":1,"hcl":1}}},"$version":8,"$root":{"transition":{"type":"transition"},"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1,"object":{}}},"default":{"type":"*","expression":1},"values":{"type":"array","value":"*"},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}},"id":{"type":"string"},"properties":{"type":"properties"}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","default":"mapbox","values":{"terrarium":1,"mapbox":1}},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"minimum":0,"maximum":512},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","default":[0,0,0],"length":3,"value":"number"}},"modelLightOverrides":{"light-ambient-color":{"type":"color"},"light-ambient-intensity":{"type":"number"},"light-directional-color":{"type":"color"},"light-directional-intensity":{"type":"number"}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","default":[0,0],"minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"orientation":{"type":"array","default":[0,0,0],"length":3,"value":"number"},"lightOverrides":{"type":"modelLightOverrides"},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"id":{"type":"string"},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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"},"appearances":{"type":"array","value":"appearance"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_sky":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_model":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"model-id":{"type":"string","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","default":[],"value":"enum","values":{"model":1,"symbol":1},"expression":1},"clip-layer-scope":{"type":"array","default":[],"value":"string","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"expression":1},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-markup":1},"expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_heatmap":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill-extrusion":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","default":3,"minimum":1,"maximum":200,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-unit-width":{"type":"number","default":3.1,"minimum":1,"maximum":20,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-window":{"type":"array","default":[0.9,0.9],"minimum":0.1,"maximum":1,"length":2,"value":"number","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-roof-shape":{"type":"enum","default":"flat","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flip-roof-orientation":{"type":"boolean","default":false,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"}},"layout_line":{"line-cap":{"type":"enum","default":"butt","values":{"butt":1,"round":1,"square":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-join":{"type":"enum","default":"miter","values":{"bevel":1,"round":1,"miter":1,"none":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["feature","line-progress","zoom"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"line-cross-slope":{"type":"number","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"line-width-unit":{"type":"enum","default":"pixels","values":{"pixels":1,"meters":1},"expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","line-progress","zoom"]},"transition":1,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","default":"point","values":{"point":1,"line":1,"line-center":1},"expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":1,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","default":"auto","values":{"auto":1,"viewport-y":1,"source":1},"expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"icon-text-fit":{"type":"enum","default":"none","values":{"none":1,"width":1,"height":1,"both":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","default":[0,0,0,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"use-theme":1,"property-type":"data-driven","appearance":1,"tokens":1},"icon-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-anchor":{"type":"enum","default":"center","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven","tokens":1},"text-font":{"type":"array","default":["Open Sans Regular","Arial Unicode MS Regular"],"value":"string","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-justify":{"type":"enum","default":"center","values":{"auto":1,"left":1,"center":1,"right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","default":"center","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","default":"none","values":{"none":1,"uppercase":1,"lowercase":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster-particle":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_hillshade":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"expression":{"parameters":["distance-from-center","feature","pitch","zoom"]},"property-type":"data-driven"},"filter_fill":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_hillshade":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster-particle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_clip":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_model":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_line":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_circle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_fill-extrusion":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_building":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_heatmap":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function_stop":{"type":"array","minimum":0,"maximum":24,"length":2,"value":["number","color"]},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"camera":{"camera-projection":{"type":"enum","default":"perspective","values":{"perspective":1,"orthographic":1}}},"colorTheme":{"data":{"type":"string","expression":1}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"projection":{"name":{"type":"enum","default":"mercator","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1}},"center":{"type":"array","minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"parallels":{"type":"array","minimum":[-90,-90],"maximum":[90,90],"length":2,"value":"number"}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-outline-color":{"type":"color","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","default":"flat","values":{"terrain":1,"flat":1}},"fill-extrusion-base-alignment":{"type":"enum","default":"terrain","values":{"terrain":1,"flat":1}},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-extrusion-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"fill-extrusion-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":1},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"use-theme":1,"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"building-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"building-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-dasharray":{"type":"array","minimum":0,"value":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-trim-offset":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number"},"line-trim-fade-range":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-trim-color":{"type":"color","default":"transparent","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-border-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-blend-mode":{"type":"enum","default":"default","values":{"default":1,"multiply":1,"additive":1},"expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-cutout-depth":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"circle-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":1,"parameters":["heatmap-density"]},"use-theme":1},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"icon-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1,"overridable":1},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"text-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"text-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":1},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven","appearance":1}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-value"]},"use-theme":1},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-range":{"type":"array","length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-scale":{"type":"enum","default":"linear","values":{"linear":1,"log":1},"expression":{"parameters":[]}},"raster-hue-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-resampling":{"type":"enum","default":"linear","values":{"linear":1,"nearest":1},"expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-elevation-reference":{"type":"enum","default":"sea","values":{"sea":1,"ground":1},"expression":1},"raster-allow-draping":{"type":"boolean","default":true}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-particle-speed"]},"use-theme":1},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":1,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"hillshade-shadow-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-accent-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_background":{"background-pitch-alignment":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_sky":{"sky-type":{"type":"enum","default":"atmosphere","values":{"gradient":1,"atmosphere":1},"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":1,"parameters":["sky-radial-progress"]},"use-theme":1},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":1},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":1},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-rotation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-scale":{"type":"array","default":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-translation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"model-color-mix-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-type":{"type":"enum","default":"common-3d","values":{"common-3d":1,"location-indicator":1}},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"model-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"model-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"model-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"model-line-cutout-mode":{"type":"enum","default":"enabled","values":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function rl(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function ol(e){if(Array.isArray(e))return e.map(ol);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={},i=e;for(const e in i)t[e]=ol(i[e]);return t}return rl(e)}function al(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(!al(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function sl(e,t="",i=null,n="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};al(e)||(e=pl(e));const r=e;let o=!0;try{o=function(e){if(!cl(e))return e;let t=ol(e);return ul(t),t=ll(t),t}(r);}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `);}let a=null,s=null;if("background"!==n&&"sky"!==n&&"slot"!==n){s=nl[`filter_${n}`];const e=ka(o,s,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(t,i,n)=>e.value.evaluate(t,i,{},n);}let l=null,u=null;if(o!==r){const e=ka(r,s,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,i,n,r,o)=>e.value.evaluate(t,i,{},n,void 0,void 0,r,o),u=!Cr(e.value.expression);}return {filter:a,dynamicFilter:l||void 0,needGeometry:fl(o),needFeature:!!u}}function ll(e){if(!Array.isArray(e))return e;const t=function(e){if(hl.has(e[0]))for(let t=1;t<e.length;t++)if(cl(e[t]))return !0;return e}(e);return !0===t?t:t.map(e=>ll(e))}function ul(e){let t=!1;const i=[];if("case"===e[0]){for(let n=1;n<e.length-1;n+=2)t=t||cl(e[n]),i.push(e[n+1]);i.push(e.at(-1));}else if("match"===e[0]){t=t||cl(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e.at(-1));}else if("step"===e[0]){t=t||cl(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1]);}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)ul(e[t]);}function cl(e){if(!Array.isArray(e))return !1;if("pitch"===(t=e[0])||"distance-from-center"===t)return !0;var t;for(let t=1;t<e.length;t++)if(cl(e[t]))return !0;return !1}const hl=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function dl(e,t){return e<t?-1:e>t?1:0}function fl(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(fl(e[t]))return !0;return !1}function pl(e){if(!e)return !0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?_l(e[1],e[2],"=="):"!="===t?yl(_l(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?_l(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(pl))):"all"===t?["all"].concat(e.slice(1).map(pl)):"none"===t?["all"].concat(e.slice(1).map(pl).map(yl)):"in"===t?ml(e[1],e.slice(2)):"!in"===t?yl(ml(e[1],e.slice(2))):"has"===t?gl(e[1]):"!has"!==t||yl(gl(e[1]));var i;}function _l(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 ml(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(dl)]]:["filter-in-small",e,["literal",t]]}}function gl(e){switch(e){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",e]}}function yl(e){return ["!",e]}const xl="";function vl(e,t){return t?`${e}${xl}${t}`:e}function bl(e){const t=e.indexOf(xl);return t>=0?e.slice(t+1):""}let wl;const El=()=>wl||(wl=new il({"icon-size":new el(nl.layout_symbol["icon-size"]),"icon-image":new el(nl.layout_symbol["icon-image"]),"icon-rotate":new el(nl.layout_symbol["icon-rotate"]),"icon-offset":new el(nl.layout_symbol["icon-offset"]),"text-size":new el(nl.layout_symbol["text-size"]),"text-rotate":new el(nl.layout_symbol["text-rotate"]),"text-offset":new el(nl.layout_symbol["text-offset"])}));let Al;const Il=()=>Al||(Al=new il({"icon-opacity":new el(nl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new el(nl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new el(nl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new el(nl.paint_symbol["text-emissive-strength"]),"icon-color":new el(nl.paint_symbol["icon-color"]),"icon-halo-color":new el(nl.paint_symbol["icon-halo-color"]),"icon-halo-width":new el(nl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new el(nl.paint_symbol["icon-halo-blur"]),"icon-translate":new el(nl.paint_symbol["icon-translate"]),"text-opacity":new el(nl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new el(nl.paint_symbol["text-occlusion-opacity"]),"text-color":new el(nl.paint_symbol["text-color"],{runtimeType:Tn,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new el(nl.paint_symbol["text-halo-color"]),"text-halo-width":new el(nl.paint_symbol["text-halo-width"]),"text-halo-blur":new el(nl.paint_symbol["text-halo-blur"]),"text-translate":new el(nl.paint_symbol["text-translate"]),"symbol-z-offset":new el(nl.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}));class Tl{constructor(e,t,i,n,r,o){this._conditionSpec=e,this._propertiesSpec=i;const a=ka(e,nl.appearance.condition);if("success"===a.result&&(this.condition=a.value),this.name=t,i){this.layoutProperties=new Ks(El()),this.unevaluatedLayout=new Ys(El(),n,r,o),this.paintProperties=new Ks(Il()),this.unevaluatedPaint=new Ys(Il(),n,r,"");for(const e in i)e in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(e,i[e]):e in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(e,i[e]);}}isActive(e){return !(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,i){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,i)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""));}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t={...this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},...this.unevaluatedPaint?this.unevaluatedPaint.serialize():{}};return Object.keys(t).length>0&&(e.properties=t),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),i=this.hasLayoutProperty("icon-offset"),n=this.hasLayoutProperty("icon-rotate");return e||t||i||n}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),i=this.hasLayoutProperty("text-rotate");return e||t||i}hasIconPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasTextPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[e].value}hasPaintProperty(e){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[e].value}}const Ml="-transition",Sl=new Set(["fill","line","background","hillshade","raster"]);class zl extends sn{constructor(e,t,i,n,r,o){if(super(),this.id=e.id,this.fqid=vl(this.id,i),this.type=e.type,this.scope=i,this.lut=n,this.options=r,this.iconImageUseTheme=o,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new Ys(t.layout,this.scope,r,this.iconImageUseTheme)),t.paint)){this._transitionablePaint=new Ws(t.paint,this.scope,r);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ks(t.paint);}}onAdd(e){}onRemove(e){}isDraped(e){return !this.is3D(!0)&&Sl.has(this.type)}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),"visibility"===e&&this.possiblyEvaluateVisibility());}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new Tl(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme));}),this.appearancesVersion++;}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(e){return e.endsWith(Ml)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return !!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const i=this._transitionablePaint,n=i._properties.properties;if(e.endsWith(Ml)){const r=e.slice(0,-11);return n[r]&&i.setTransition(r,t||void 0),!1}if(!n[e])return !1;const r=i._values[e],o=r.value.isDataDriven(),a=r.value;i.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=i._values[e].value,l=s.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return l||o||u||this._handleOverridablePaintPropertyUpdate(e,a,s)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return !1}isHidden(e){return !!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){const e={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),dt(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return !1}hasElevation(){return !1}mayUse(e){return !1}prepare(){return Promise.resolve()}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Js&&Ta(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}for(const e of this.appearances)if(!Fr(e.condition.expression))return !0;return !1}compileFilter(e){this._filterCompiled||(this._featureFilter=sl(this.filter,this.scope,e),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,i){return {}}queryRadius(e){}queryIntersectsFeature(e,t,i,n,r,o,a,s,l,u){}}function Rl(e,t,i){if(!e._unevaluatedLayout)return !1;const n=e._unevaluatedLayout.getValue(t);return void 0!==n&&("string"!=typeof n||i(n))}function Pl(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let o=Dl(e,0,r,i,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,u;if(n&&(o=function(e,t,i,n){const r=[];for(let i=0,o=t.length;i<o;i++){const a=Dl(e,t[i]*n,i<o-1?t[i+1]*n:e.length,n,!1);a===a.next&&(a.steiner=!0),r.push(jl(a));}r.sort(Vl);for(let e=0;e<r.length;e++)i=kl(r[e],i);return i}(e,t,o,i)),e.length>80*i){s=e[0],l=e[1];let t=s,n=l;for(let o=i;o<r;o+=i){const i=e[o],r=e[o+1];i<s&&(s=i),r<l&&(l=r),i>t&&(t=i),r>n&&(n=r);}u=Math.max(t-s,n-l),u=0!==u?32767/u:0;}return Fl(o,a,i,s,l,u,0),a}function Dl(e,t,i,n,r){let o;if(r===function(e,t,i,n){let r=0;for(let o=t,a=i-n;o<i;o+=n)r+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return r}(e,t,i,n)>0)for(let r=t;r<i;r+=n)o=eu(r/n|0,e[r],e[r+1],o);else for(let r=i-n;r>=t;r-=n)o=eu(r/n|0,e[r],e[r+1],o);return o&&ql(o,o.next)&&(tu(o),o=o.next),o}function Cl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!ql(n,n.next)&&0!==Wl(n.prev,n,n.next))n=n.next;else {if(tu(n),n=t=n.prev,n===n.next)break;i=!0;}}while(i||n!==t);return t}function Fl(e,t,i,n,r,o,a){if(!e)return;!a&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Gl(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let a=r,s=0;for(let e=0;e<i&&(s++,a=a.nextZ,a);e++);let l=i;for(;s>0||l>0&&a;)0!==s&&(0===l||!a||r.z<=a.z)?(n=r,r=r.nextZ,s--):(n=a,a=a.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=a;}o.nextZ=null,i*=2;}while(t>1)}(r);}(e,n,r,o);let s=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(o?Ll(e,n,r,o):Ol(e))t.push(l.i,e.i,u.i),tu(e),e=u.next,s=u.next;else if((e=u)===s){a?1===a?Fl(e=Bl(Cl(e),t),t,i,n,r,o,2):2===a&&Nl(e,t,i,n,r,o):Fl(Cl(e),t,i,n,r,o,1);break}}}function Ol(e){const t=e.prev,i=e,n=e.next;if(Wl(t,i,n)>=0)return !1;const r=t.x,o=i.x,a=n.x,s=t.y,l=i.y,u=n.y,c=Math.min(r,o,a),h=Math.min(s,l,u),d=Math.max(r,o,a),f=Math.max(s,l,u);let p=n.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&$l(r,s,o,l,a,u,p.x,p.y)&&Wl(p.prev,p,p.next)>=0)return !1;p=p.next;}return !0}function Ll(e,t,i,n){const r=e.prev,o=e,a=e.next;if(Wl(r,o,a)>=0)return !1;const s=r.x,l=o.x,u=a.x,c=r.y,h=o.y,d=a.y,f=Math.min(s,l,u),p=Math.min(c,h,d),_=Math.max(s,l,u),m=Math.max(c,h,d),g=Gl(f,p,t,i,n),y=Gl(_,m,t,i,n);let x=e.prevZ,v=e.nextZ;for(;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==r&&x!==a&&$l(s,c,l,h,u,d,x.x,x.y)&&Wl(x.prev,x,x.next)>=0)return !1;if(x=x.prevZ,v.x>=f&&v.x<=_&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&$l(s,c,l,h,u,d,v.x,v.y)&&Wl(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;x&&x.z>=g;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==r&&x!==a&&$l(s,c,l,h,u,d,x.x,x.y)&&Wl(x.prev,x,x.next)>=0)return !1;x=x.prevZ;}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&$l(s,c,l,h,u,d,v.x,v.y)&&Wl(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function Bl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!ql(n,r)&&Xl(n,i,i.next,r)&&Kl(n,r)&&Kl(r,n)&&(t.push(n.i,i.i,r.i),tu(i),tu(i.next),i=e=r),i=i.next;}while(i!==e);return Cl(i)}function Nl(e,t,i,n,r,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Zl(a,e)){let s=Ql(a,e);return a=Cl(a,a.next),s=Cl(s,s.next),Fl(a,t,i,n,r,o,0),void Fl(s,t,i,n,r,o,0)}e=e.next;}a=a.next;}while(a!==e)}function Vl(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 kl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,a=-1/0;if(ql(e,i))return i;do{if(ql(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>a&&(a=e,o=i.x<i.next.x?i:i.next,e===n))return o}i=i.next;}while(i!==t);if(!o)return null;const s=o,l=o.x,u=o.y;let c=1/0;i=o;do{if(n>=i.x&&i.x>=l&&n!==i.x&&Hl(r<u?n:a,r,l,u,r<u?a:n,r,i.x,i.y)){const t=Math.abs(r-i.y)/(n-i.x);Kl(i,e)&&(t<c||t===c&&(i.x>o.x||i.x===o.x&&Ul(o,i)))&&(o=i,c=t);}i=i.next;}while(i!==s);return o}(e,t);if(!i)return t;const n=Ql(i,e);return Cl(n,n.next),Cl(i,i.next)}function Ul(e,t){return Wl(e.prev,e,t.prev)<0&&Wl(t.next,e,e.next)<0}function Gl(e,t,i,n,r){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jl(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 Hl(e,t,i,n,r,o,a,s){return (r-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(n-s)>=(i-a)*(t-s)&&(i-a)*(o-s)>=(r-a)*(n-s)}function $l(e,t,i,n,r,o,a,s){return !(e===a&&t===s)&&Hl(e,t,i,n,r,o,a,s)}function Zl(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&&Xl(i,i.next,e,t))return !0;i=i.next;}while(i!==e);return !1}(e,t)&&(Kl(e,t)&&Kl(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next;}while(i!==e);return n}(e,t)&&(Wl(e.prev,e,t.prev)||Wl(e,t.prev,t))||ql(e,t)&&Wl(e.prev,e,e.next)>0&&Wl(t.prev,t,t.next)>0)}function Wl(e,t,i){return (t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ql(e,t){return e.x===t.x&&e.y===t.y}function Xl(e,t,i,n){const r=Jl(Wl(e,t,i)),o=Jl(Wl(e,t,n)),a=Jl(Wl(i,n,e)),s=Jl(Wl(i,n,t));return r!==o&&a!==s||!(0!==r||!Yl(e,i,t))||!(0!==o||!Yl(e,n,t))||!(0!==a||!Yl(i,e,n))||!(0!==s||!Yl(i,t,n))}function Yl(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 Jl(e){return e>0?1:e<0?-1:0}function Kl(e,t){return Wl(e.prev,e,e.next)<0?Wl(e,t,e.next)>=0&&Wl(e,e.prev,t)>=0:Wl(e,t,e.prev)<0||Wl(e,e.next,t)<0}function Ql(e,t){const i=iu(e.i,e.x,e.y),n=iu(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function eu(e,t,i,n){const r=iu(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function tu(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 iu(e,t,i){return {i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function nu(e,t,i=1){if(!e)return null;const n="string"==typeof e?Gn.from(e).getPrimary():e.getPrimary(),r="string"==typeof e?null:e.getSecondary();for(const e of [n,r]){if(!e)continue;const n=e.id.toString();t.has(n)||t.set(n,[]),e.scaleSelf(i),t.get(n).push(e);}return {primary:n.toString(),secondary:r?r.toString():null}}function ru(e,t,i,n){const r=n.patternDependencies;let o=!1;for(const n of t){const t=n.paint.get(`${e}-pattern`);t.isConstant()||(o=!0),nu(t.constantOr(null),r,i)&&(o=!0);}return o}function ou(e,t,i,n,r,o){const a=o.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){const e=nu(t.evaluate({zoom:n},i,{},void 0,o.availableImages),a,r);if(!e)continue;const{primary:l,secondary:u}=e;l&&(i.patterns[s.id]=[l,u].filter(Boolean));}}return i}const au=Sr/Math.PI/2,su=64,lu=[su,32,16],uu=-au,cu=au;function hu(e,t,i,n=au){return i=Ye(i),[e*Math.sin(i)*n,-t*n,e*Math.cos(i)*n]}function du(e,t,i){return hu(Math.cos(Ye(e)),Math.sin(Ye(e)),t,i)}const fu=6371008.8,pu=2*Math.PI*fu;class _u{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 _u(nt(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return fu*Math.acos(Math.min(r,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new mu({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return du(this.lat,this.lng,au+e*au/fu)}static convert(e){if(e instanceof _u)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new _u(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new _u(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 mu{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 _u?new _u(e.lng,e.lat):_u.convert(e),this}setSouthWest(e){return this._sw=e instanceof _u?new _u(e.lng,e.lat):_u.convert(e),this}extend(e){const t=this._sw,i=this._ne;let n,r;if(e instanceof _u)n=e,r=e;else {if(!(e instanceof mu))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(mu.convert(e)):this.extend(_u.convert(e)):"object"==typeof e&&null!==e&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(_u.convert(e)):this;if(n=e._sw,r=e._ne,!n||!r)return this}return t||i?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new _u(n.lng,n.lat),this._ne=new _u(r.lng,r.lat)),this}getCenter(){return new _u((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 _u(this.getWest(),this.getNorth())}getSouthEast(){return new _u(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}=_u.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}static convert(e){if(e)return e instanceof mu?e:new mu(e)}}function gu(e){return pu*Math.cos(e*Math.PI/180)}function yu(e,t){return e/gu(t)}function xu(e,t){return e*gu(pr(t))}const vu=85.051129;function bu(e){return Math.cos(Ye(tt(e,-85.051129,vu)))}function wu(e,t){const i=tt(t,0,25.5),n=Math.pow(2,i);return bu(e)*pu/(512*n)}function Eu(e){return 1/Math.cos(e*Math.PI/180)}function Au(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Sr)/(1<<e.z)*2));return 80150034*i/(i*i+1)/Sr/(1<<e.z)}class Iu{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i;}static fromLngLat(e,t=0){const i=_u.convert(e);return new Iu(hr(i.lng),dr(i.lat),yu(t,i.lat))}toLngLat(){return new _u(fr(this.x),pr(this.y))}toAltitude(){return xu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/pu*Eu(pr(this.y))}}function Tu(e,t,i,n,r,o,a,s,l){const u=(t+n)/2,c=(i+r)/2,h=new Pe(u,c);s(h),function(e,t,i,n,r,o){const a=i-r,s=n-o;return Math.abs((n-t)*a-(i-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Tu(e,t,i,u,c,o,h,s,l),Tu(e,u,c,n,r,h,a,s,l)):e.push(a);}function Mu(e,t,i){let n=e[0],r=n.x,o=n.y;t(n);const a=[n];for(let s=1;s<e.length;s++){const l=e[s],{x:u,y:c}=l;t(l),Tu(a,r,o,u,c,n,l,t,i),r=u,o=c,n=l;}return a}function Su(e,t,i,n){if(n(t,i)){const r=t.add(i)._mult(.5);Su(e,t,r,n),Su(e,r,i,n);}else e.push(i);}function zu(e,t){let i=e[0];const n=[i];for(let r=1;r<e.length;r++){const o=e[r];Su(n,i,o,t),i=o;}return n}const Ru=Math.pow(2,14)-1,Pu=-Ru-1;function Du(e,t){const i=Math.round(e.x*t),n=Math.round(e.y*t);return e.x=tt(i,Pu,Ru),e.y=tt(n,Pu,Ru),(i<e.x||i>e.x+1||n<e.y||n>e.y+1)&&mt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Cu(e,t,i){const n=e.loadGeometry(),r=e.extent,o=Sr/r;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:a,x:s,y:l,projection:u}=i,c=e=>{const i=fr((t.x+e.x/r)/o),n=pr((t.y+e.y/r)/o),c=u.project(i,n);e.x=(c.x*a-s)*r,e.y=(c.y*a-l)*r;};for(let t=0;t<n.length;t++)if(1!==e.type)n[t]=Mu(n[t],c,1);else {const e=[];for(const i of n[t])i.x<0||i.x>=r||i.y<0||i.y>=r||(c(i),e.push(i));n[t]=e;}}for(const e of n)for(const t of e)Du(t,o);return n}function Fu(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?Cu(e):[]}}const Ou={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Lu{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;}}const Bu=new ArrayBuffer(0);class Nu{constructor(){this._reallocCount=0,this.capacity=0,this.length=0;}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(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,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=Bu),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;}resizeExact(e){this.reserveExact(e),this.length=e;}reserve(e){e>this.capacity&&this._allocate(Math.max(e,Math.floor(5*this.capacity),128));}reserveExact(e){(e>this.capacity||!this.arrayBuffer)&&this._allocate(e);}_allocate(e){this._reallocCount++,this.capacity=e,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}reserveForAdditional(e){this.reserve(this.length+e);}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function Vu(e,t=1){let i=0,n=0;return {members:e.map(e=>{const r=Ou[e.type].BYTES_PER_ELEMENT,o=i=ku(i,Math.max(t,r)),a=e.components||1;return n=Math.max(n,r),i+=r*a,{name:e.name,type:e.type,components:a,offset:o}}),size:ku(i,Math.max(n,t)),alignment:t}}function ku(e,t){return Math.ceil(e/t)*t}class Uu extends Nu{_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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}Uu.prototype.bytesPerElement=4,qa(Uu,"StructArrayLayout2i4");class Gu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Gu.prototype.bytesPerElement=6,qa(Gu,"StructArrayLayout3i6");class ju extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,e}}ju.prototype.bytesPerElement=8,qa(ju,"StructArrayLayout2i2ui8");class Hu extends Nu{_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}}Hu.prototype.bytesPerElement=4,qa(Hu,"StructArrayLayout1f4");class $u extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e,o=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.float32[o+1]=n,e}}$u.prototype.bytesPerElement=8,qa($u,"StructArrayLayout2i1f8");class Zu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Zu.prototype.bytesPerElement=8,qa(Zu,"StructArrayLayout3i8");class Wu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}Wu.prototype.bytesPerElement=8,qa(Wu,"StructArrayLayout4i8");class qu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const a=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,e}}qu.prototype.bytesPerElement=10,qa(qu,"StructArrayLayout5i10");class Xu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o,a)}emplace(e,t,i,n,r,o,a,s){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[u+4]=n,this.uint8[u+5]=r,this.uint8[u+6]=o,this.uint8[u+7]=a,this.float32[c+2]=s,e}}Xu.prototype.bytesPerElement=12,qa(Xu,"StructArrayLayout2i4ub1f12");class Yu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}Yu.prototype.bytesPerElement=12,qa(Yu,"StructArrayLayout3f12");class Ju extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const a=6*e,s=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=i,this.uint16[a+2]=n,this.uint16[a+3]=r,this.float32[s+2]=o,e}}Ju.prototype.bytesPerElement=12,qa(Ju,"StructArrayLayout4ui1f12");class Ku extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,e}}Ku.prototype.bytesPerElement=8,qa(Ku,"StructArrayLayout4ui8");class Qu extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,this.int16[s+5]=a,e}}Qu.prototype.bytesPerElement=12,qa(Qu,"StructArrayLayout6i12");class ec extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,a,s,l,u,c,h)}emplace(e,t,i,n,r,o,a,s,l,u,c,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=d,e}}ec.prototype.bytesPerElement=24,qa(ec,"StructArrayLayout4i4ui4i24");class tc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=a,e}}tc.prototype.bytesPerElement=20,qa(tc,"StructArrayLayout3i3f20");class ic extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}ic.prototype.bytesPerElement=16,qa(ic,"StructArrayLayout4f16");class nc extends Nu{_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}}nc.prototype.bytesPerElement=4,qa(nc,"StructArrayLayout1ul4");class rc extends Nu{_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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}rc.prototype.bytesPerElement=4,qa(rc,"StructArrayLayout2ui4");class oc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,i,n,r,o,a,s,l,u,c,h,d)}emplace(e,t,i,n,r,o,a,s,l,u,c,h,d,f){const p=20*e,_=10*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.int16[p+4]=o,this.float32[_+3]=a,this.float32[_+4]=s,this.float32[_+5]=l,this.float32[_+6]=u,this.int16[p+14]=c,this.uint32[_+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}oc.prototype.bytesPerElement=40,qa(oc,"StructArrayLayout5i4f1i1ul2ui40");class ac extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o,a)}emplace(e,t,i,n,r,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}ac.prototype.bytesPerElement=16,qa(ac,"StructArrayLayout3i2i2i16");class sc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=n,this.int16[s+6]=r,this.int16[s+7]=o,e}}sc.prototype.bytesPerElement=16,qa(sc,"StructArrayLayout2f1f2i16");class lc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,a){const s=20*e,l=5*e;return this.uint8[s+0]=t,this.uint8[s+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=a,e}}lc.prototype.bytesPerElement=20,qa(lc,"StructArrayLayout2ub4f20");class uc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}uc.prototype.bytesPerElement=6,qa(uc,"StructArrayLayout3ui6");class cc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v)}emplace(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v,b){const w=30*e,E=15*e,A=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[E+2]=r,this.float32[E+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[E+5]=l,this.uint32[E+6]=u,this.uint32[E+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[E+10]=p,this.float32[E+11]=_,this.uint8[A+48]=m,this.uint8[A+49]=g,this.uint8[A+50]=y,this.uint32[E+13]=x,this.int16[w+28]=v,this.uint8[A+58]=b,e}}cc.prototype.bytesPerElement=60,qa(cc,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class hc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v,b,w,E,A,I,T,M,S,z,R,P,D){const C=this.length;return this.resize(C+1),this.emplace(C,e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v,b,w,E,A,I,T,M,S,z,R,P,D)}emplace(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v,b,w,E,A,I,T,M,S,z,R,P,D,C){const F=20*e,O=40*e,L=80*e;return this.float32[F+0]=t,this.float32[F+1]=i,this.int16[O+4]=n,this.int16[O+5]=r,this.int16[O+6]=o,this.int16[O+7]=a,this.int16[O+8]=s,this.int16[O+9]=l,this.int16[O+10]=u,this.int16[O+11]=c,this.int16[O+12]=h,this.uint16[O+13]=d,this.uint16[O+14]=f,this.uint16[O+15]=p,this.uint16[O+16]=_,this.uint16[O+17]=m,this.uint16[O+18]=g,this.uint16[O+19]=y,this.uint16[O+20]=x,this.uint16[O+21]=v,this.uint16[O+22]=b,this.uint16[O+23]=w,this.uint16[O+24]=E,this.uint16[O+25]=A,this.uint16[O+26]=I,this.uint16[O+27]=T,this.uint32[F+14]=M,this.float32[F+15]=S,this.float32[F+16]=z,this.float32[F+17]=R,this.float32[F+18]=P,this.uint8[L+76]=D,this.uint16[O+39]=C,e}}hc.prototype.bytesPerElement=80,qa(hc,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class dc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,a){const s=6*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,this.float32[s+5]=a,e}}dc.prototype.bytesPerElement=24,qa(dc,"StructArrayLayout6f24");class fc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=n,this.float32[a+3]=r,this.float32[a+4]=o,e}}fc.prototype.bytesPerElement=20,qa(fc,"StructArrayLayout5f20");class pc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o,a)}emplace(e,t,i,n,r,o,a,s){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=a,this.float32[l+6]=s,e}}pc.prototype.bytesPerElement=28,qa(pc,"StructArrayLayout7f28");class _c extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,n,r,o,a,s,l,u,c)}emplace(e,t,i,n,r,o,a,s,l,u,c,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=i,this.float32[d+2]=n,this.float32[d+3]=r,this.float32[d+4]=o,this.float32[d+5]=a,this.float32[d+6]=s,this.float32[d+7]=l,this.float32[d+8]=u,this.float32[d+9]=c,this.float32[d+10]=h,e}}_c.prototype.bytesPerElement=44,qa(_c,"StructArrayLayout11f44");class mc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,a,s,l)}emplace(e,t,i,n,r,o,a,s,l,u){const c=9*e;return this.float32[c+0]=t,this.float32[c+1]=i,this.float32[c+2]=n,this.float32[c+3]=r,this.float32[c+4]=o,this.float32[c+5]=a,this.float32[c+6]=s,this.float32[c+7]=l,this.float32[c+8]=u,e}}mc.prototype.bytesPerElement=36,qa(mc,"StructArrayLayout9f36");class gc extends Nu{_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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}gc.prototype.bytesPerElement=8,qa(gc,"StructArrayLayout2f8");class yc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,e}}yc.prototype.bytesPerElement=12,qa(yc,"StructArrayLayout1ul3ui12");class xc extends Nu{_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}}xc.prototype.bytesPerElement=2,qa(xc,"StructArrayLayout1ui2");class vc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_){const m=this.length;return this.resize(m+1),this.emplace(m,e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_)}emplace(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=a,this.float32[g+6]=s,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=f,this.float32[g+13]=p,this.float32[g+14]=_,this.float32[g+15]=m,e}}vc.prototype.bytesPerElement=64,qa(vc,"StructArrayLayout16f64");class bc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,n,r,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o,a)}emplace(e,t,i,n,r,o,a,s){const l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[u+2]=o,this.float32[u+3]=a,this.float32[u+4]=s,e}}bc.prototype.bytesPerElement=20,qa(bc,"StructArrayLayout4ui3f20");class wc extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}wc.prototype.bytesPerElement=2,qa(wc,"StructArrayLayout1i2");class Ec extends Nu{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}Ec.prototype.bytesPerElement=1,qa(Ec,"StructArrayLayout1ub1");class Ac extends Lu{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Ac.prototype.size=40;class Ic extends oc{get(e){return new Ac(this,e)}}qa(Ic,"CollisionBoxArray");class Tc extends Lu{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}Tc.prototype.size=60;class Mc extends cc{get(e){return new Tc(this,e)}}qa(Mc,"PlacedSymbolArray");class Sc extends Lu{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}Sc.prototype.size=80;class zc extends hc{get(e){return new Sc(this,e)}}qa(zc,"SymbolInstanceArray");class Rc extends Hu{getoffsetX(e){return this.float32[1*e+0]}}qa(Rc,"GlyphOffsetArray");class Pc extends Uu{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}qa(Pc,"SymbolLineVertexArray");class Dc extends Lu{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Dc.prototype.size=12;class Cc extends yc{get(e){return new Dc(this,e)}}qa(Cc,"FeatureIndexArray");class Fc extends rc{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}qa(Fc,"FillExtrusionCentroidArray");class Oc extends Lu{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Oc.prototype.size=6;class Lc extends Gu{get(e){return new Oc(this,e)}}qa(Lc,"FillExtrusionWallArray");const Bc=Vu([{name:"a_pos",components:2,type:"Int16"}],4),Nc=Vu([{name:"a_road_z_offset",components:1,type:"Float32"}],4),Vc=Vu([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),kc=Vu([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class Uc{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,i,n,r){let o=this.segments.at(-1);return e>Uc.MAX_VERTEX_ARRAY_LENGTH&&mt(`Max vertices per segment is ${Uc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!o||o.vertexLength+e>Uc.MAX_VERTEX_ARRAY_LENGTH||o.sortKey!==n||void 0!==r&&o&&void 0!==o.batchIndex&&o.batchIndex!==r)&&(o={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(o.sortKey=n),void 0!==r&&(o.batchIndex=r),this.segments.push(o)),o}prepareSegment(e,t,i,n,r){return this._prepareSegment(e,t.length,i.length,n,r)}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,n){return new Uc([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Gc(e,t){return 256*(e=tt(Math.floor(e),0,255))+tt(Math.floor(t),0,255)}Uc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,qa(Uc,"SegmentVector");const jc=Vu([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Hc=Vu([{name:"a_pattern_b",components:4,type:"Uint16"}]),$c=Vu([{name:"a_dash",components:4,type:"Uint16"}]);class Zc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,i,n){this.ids.push(Wc(e)),this.positions.push(t,i,n);}eachPosition(e,t){const i=Wc(e);let n=0,r=this.ids.length-1;for(;n<r;){const e=n+r>>1;this.ids[e]>=i?r=e:n=e+1;}for(;this.ids[n]===i;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return qc(i,n,0,i.length-1),t&&(t.add(i.buffer),t.add(n.buffer)),{ids:i,positions:n}}static deserialize(e){const t=new Zc;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function Wc(e){const t=+e;return Number.isSafeInteger(t)?t:tn(String(e))}function qc(e,t,i,n){for(;i<n;){const r=e[i+n>>1];let o=i-1,a=n+1;for(;;){do{o++;}while(e[o]<r);do{a--;}while(e[a]>r);if(o>=a)break;Xc(e,o,a),Xc(t,3*o,3*a),Xc(t,3*o+1,3*a+1),Xc(t,3*o+2,3*a+2);}a-i<n-a?(qc(e,t,i,a),i=a+1):(qc(e,t,a+1,n),n=a);}}function Xc(e,t,i){const n=e[t];e[t]=e[i],e[i]=n;}qa(Zc,"FeaturePositionMap");class Yc{constructor(e){this.gl=e.gl,this.initialized=!1;}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,i){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class Jc extends Yc{constructor(e){super(e),this.current=0;}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i));}}class Kc extends Yc{constructor(e){super(e),this.current=0;}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i));}}class Qc extends Yc{constructor(e){super(e),this.current=[0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])));}}class eh extends Yc{constructor(e){super(e),this.current=[0,0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])));}}class th extends Yc{constructor(e){super(e),this.current=[0,0,0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4ui(this.location,i[0],i[1],i[2],i[3])));}}class ih extends Yc{constructor(e){super(e),this.current=[0,0,0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])));}}class nh extends Yc{constructor(e){super(e),this.current=pn.transparent.toPremultipliedRenderColor(null);}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)));}}class rh extends Yc{constructor(e){super(e),this.current=new Float32Array(16);}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;if(i[12]!==n[12]||i[0]!==n[0])return n.set(i),void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix4fv(this.location,!1,n);break}}}class oh extends Yc{constructor(e){super(e),this.current=new Float32Array(4);}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<4;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix2fv(this.location,!1,n);break}}}function ah(e){return [Gc(255*e.r,255*e.g),Gc(255*e.b,255*e.a)]}function sh(e,t,i,n,r,o,a,s){return !!e&&("composite"===e.kind||"source"===e.kind?"none"===e.evaluate(new Hs(0,{brightness:o,worldview:s}),t,i,r,n,a):"none"===e.value)}class lh{constructor(e,t,i,n){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i,this.context=n;}setUniform(e,t,i,n,r){const o=n.constantOr(this.value);t.set(e,r,o instanceof pn?o.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):o);}getBinding(e,t){return "color"===this.type?new nh(e):new Kc(e)}}class uh{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1;}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern;}setUniform(e,t,i,n,r){let o=null;"u_pattern"!==r&&"u_dash"!==r||(o=this.pattern),"u_pattern_b"===r&&(o=this.patternTransition),"u_pixel_ratio"===r&&(o=this.pixelRatio),o&&t.set(e,r,o);}getBinding(e,t){return "u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new th(e):new Kc(e)}}class ch{constructor(e,t,i,n){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 n;}populatePaintArray(e,t,i,n,r,o,a,s){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Hs(0,{brightness:o,worldview:s}),t,{},r,n,a):"constant"===this.expression.kind&&this.expression.value,c=sh(this.lutExpression,t,{},n,r,o,a,s);this.paintVertexArray.resize(e),this._setPaintValue(l,e,u,c?null:this.context.lut);}updatePaintArray(e,t,i,n,r,o,a,s){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:a,worldview:s},i,n,void 0,r):"constant"===this.expression.kind&&this.expression.value,u=sh(this.lutExpression,i,n,r,void 0,a,void 0,s);this._setPaintValue(e,t,l,u?null:this.context.lut);}_setPaintValue(e,t,i,n){if("color"===this.type){const r=ah(i.toPremultipliedRenderColor(n));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1]);}else {for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i);this.maxValue=Math.max(this.maxValue,Math.abs(i));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class hh{constructor(e,t,i,n,r,o){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.context=r,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,n,r,o,a,s){const l=this.expression.evaluate(new Hs(this.context.zoom,{brightness:o,worldview:s}),t,{},r,n,a),u=this.expression.evaluate(new Hs(this.context.zoom+1,{brightness:o,worldview:s}),t,{},r,n,a),c=sh(this.lutExpression,t,{},n,r,o,a,s),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,u,c?null:this.context.lut);}updatePaintArray(e,t,i,n,r,o,a,s){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:a,worldview:s},i,n,void 0,r),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a,worldview:s},i,n,void 0,r),c=sh(this.lutExpression,i,n,r,void 0,a,void 0,s);this._setPaintValue(e,t,l,u,c?null:this.context.lut);}_setPaintValue(e,t,i,n,r){if("color"===this.type){const o=ah(i.toPremultipliedRenderColor(r)),a=ah(n.toPremultipliedRenderColor(r));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,o[0],o[1],a[0],a[1]);}else {for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i,n);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(n));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}setUniform(e,t,i,n,r){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=tt(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);t.set(e,r,a);}getBinding(e,t){return new Kc(e)}}class dh{constructor(e,t,i,n,r){this.expression=e,this.layerId=r,this.paintVertexAttributes=("array"===i?$c:jc).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new n,this.paintTransitionVertexArray=new Ku;}populatePaintArray(e,t,i,n){const r=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i);}updatePaintArray(e,t,i,n,r,o,a){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o);}_setPaintValues(e,t,i,n){if(!n||!i)return;const r=n[i[0]],o=n[i[1]];if(r){if(r){const{tl:i,br:n,pixelRatio:o}=r;for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i[0],i[1],n[0],n[1],o);}if(o){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:i,br:n}=o;for(let r=e;r<t;r++)this.paintTransitionVertexArray.emplace(r,i[0],i[1],n[0],n[1]);}}}upload(e){const t=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,t)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,Hc.members,t));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy();}}class fh{constructor(e,t,i=()=>!0){this.binders={},this._buffers=[],this.context=t;const n=[],r=e;for(const o in e.paint._values){const a=r.paint.get(o);if(o.endsWith("-use-theme"))continue;if(!i(o))continue;if(!(a instanceof Js&&Ta(a.property.specification)))continue;const s=mh(o,e.type),l=a.value,u=a.property.specification.type,c=!!a.property.useIntegerZoom,h="line-dasharray"===o||o.endsWith("pattern"),d=r.paint.get(`${o}-use-theme`),f="line-dasharray"===o&&"constant"!==r.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||f)if("source"===l.kind||f||h){const t=xh(o,u,"source");this.binders[o]=h?new dh(l,s,u,t,e.id):new ch(l,s,u,t),n.push(`/a_${o}`);}else {const e=xh(o,u,"composite");this.binders[o]=new hh(l,s,u,c,t,e),n.push(`/z_${o}`);}else this.binders[o]=h?new uh(l.value,s):new lh(l.value,s,u,t),n.push(`/u_${o}`);d&&(this.binders[o].lutExpression=d.value);}this.cacheKey=n.sort().join("");}updateExpressions(e){const t=e;for(const e in this.binders){const i=this.binders[e];if(i instanceof ch||i instanceof hh||i instanceof dh){const n=t.paint.get(e);i.expression=n.value;}}}getMaxValue(e){const t=this.binders[e];return t instanceof ch||t instanceof hh?t.maxValue:0}populatePaintArrays(e,t,i,n,r,o,a,s){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof ch||u instanceof hh||u instanceof dh)&&u.populatePaintArray(e,t,i,n,r,o,a,s);}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof uh&&n.setConstantPatternPositions(e,t);}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof dh?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,i,n,r,o,a,s,l,u){let c=!1;const h=Object.keys(e),d=0!==h.length&&!s,f=d?h:t.uniqueIds;this.context.lut=r.lut;for(const s in this.binders){const h=this.binders[s];if(h.context=this.context,(h instanceof ch||h instanceof hh||h instanceof dh)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=r.paint.get(s);h.expression=p.value;for(const i of f){const r=e[i.toString()];t.eachPosition(i,(e,t,i)=>{const s=n.feature(e);h.updatePaintArray(t,i,s,r,o,a,l,u);});}if(!d)for(const t of i.uniqueIds){const r=e[t.toString()];i.eachPosition(t,(e,t,i)=>{const s=n.feature(e);h.updatePaintArray(t,i,s,r,o,a,l,u);});}c=!0;}}return c}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof lh||i instanceof uh)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`));}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof lh||n instanceof uh||n instanceof hh)for(const r of n.uniformNames)t.push({name:r,property:i,binding:n.getBinding(e,r)});}return t}setUniforms(e,t,i,n,r){for(const{name:t,property:o,binding:a}of i)this.binders[o].setUniform(e,a,r,n.get(o),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof ch||t instanceof hh||t instanceof dh)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof dh&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer);}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof ch||i instanceof hh||i instanceof dh)&&i.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof ch||t instanceof hh||t instanceof dh)&&t.destroy();}}}class ph{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new fh(n,t,i);this.needsUpload=!1,this._featureMap=new Zc,this._featureMapWithoutIds=new Zc,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,i,n,r,o,a,s,l){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,o,a,s,l);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,i,n,r,o,a,s){for(const l of i)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,r,o,a||0,s)||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();}updateExpressions(e){const t=new Set;for(const i of e){const e=this.programConfigurations[i.id];e&&(e.updateExpressions(i),t.add(i.id));}for(const e in this.programConfigurations)t.has(e)||delete this.programConfigurations[e];}}const _h={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function mh(e,t){return _h[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const gh={"line-pattern":{source:Ju,composite:Ju},"fill-pattern":{source:Ju,composite:Ju},"fill-extrusion-pattern":{source:Ju,composite:Ju},"line-dasharray":{source:Ku,composite:Ku}},yh={color:{source:gc,composite:ic},number:{source:Hu,composite:gc}};function xh(e,t,i){const n=gh[e];return n&&n[i]||yh[t][i]}qa(lh,"ConstantBinder"),qa(uh,"PatternConstantBinder"),qa(ch,"SourceExpressionBinder",{omit:["expression"]}),qa(dh,"PatternCompositeBinder",{omit:["expression"]}),qa(hh,"CompositeExpressionBinder",{omit:["expression"]}),qa(fh,"ProgramConfiguration",{omit:["_buffers"]}),qa(ph,"ProgramConfigurationSet");class vh{constructor(e,t,i){this.layoutVertexArray=new Uu,this.indexArray=new uc,this.lineIndexArray=new rc,this.triangleSegments=new Uc,this.lineSegments=new Uc,this.programConfigurations=new ph(e,{zoom:t,lut:i}),this.uploaded=!1;}update(e,t,i,n,r,o,a,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,s);}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Bc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy());}populatePaintArrays(e,t,i,n,r,o,a){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,n,r,o,void 0,a);}}qa(vh,"FillBufferData");class bh{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new vh(e.layers,e.zoom,e.lut),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.sourceLayerIndex=e.sourceLayerIndex,this.sourceLayerName=e.sourceLayerName||"",this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.hasPattern=ru("fill",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Fu(a,e);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const h=r?r.evaluate(c,{},i,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Cu(a,i,n),patterns:{},sortKey:h};o.push(d);}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:a}=n;if(this.hasPattern){const e=ou("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,r,o,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[o].feature,r,o,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this);}update(e,t,i,n,r,o,a){this.bufferData.update(e,t,i,n,r,o,a,this.worldview),this.hdExt&&this.hdExt.update(e,t,i,n,r,o,a,this.worldview);}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.hdExt&&this.hdExt.updateExpressions(e);}addFeatures(e,t,i,n,r,o){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,o,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this);}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return !this.uploaded||this.bufferData.needsUpload()||null!=this.hdExt&&this.hdExt.needsUpload()}upload(e){this.bufferData.upload(e),this.hdExt&&this.hdExt.upload(e);}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy();}addFeature(e,t,i,n,r,o=[],a,s){const l=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,u=this.bufferData.indexArray.length,c=Ne(t,500);null!=this.hdExt&&this.hdExt.handleFeature(e,c,i,n,s,this)||this.addGeometry(c,this.bufferData),this.bufferData.populatePaintArrays(e,i,r,o,n,a,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(e,i,r,o,n,a,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,u,this.bufferData.indexArray.length,l);}addGeometry(e,t,i,n){let r=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=null;i&&(a=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=a&&(r=a,o=a));const s=i?t:null,l=(e,t,n)=>{if(null!=i)if(t.push(e),null!=a)s.elevatedLayoutVertexArray.emplaceBack(a),n.push(a);else {const t=i.elevationSampler.pointElevation(e,i.elevation,i.bias);s.elevatedLayoutVertexArray.emplaceBack(t),n.push(t),r=Math.min(r,t),o=Math.max(o,t);}};for(const r of e){let e=0;for(const t of r)e+=t.length;const o=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),a=o.vertexLength,s=[],u=[],c=[],h=[],d=[],f=t.layoutVertexArray.length;for(const e of r){if(0===e.length)continue;e!==r[0]&&u.push(s.length/2);const n=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=n.vertexLength;i&&d.push(t.layoutVertexArray.length-f),l(e[0],c,h),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),s.push(e[0].x),s.push(e[0].y);for(let i=1;i<e.length;i++)l(e[i],c,h),t.layoutVertexArray.emplaceBack(e[i].x,e[i].y),t.lineIndexArray.emplaceBack(o+i-1,o+i),s.push(e[i].x),s.push(e[i].y);n.vertexLength+=e.length,n.primitiveLength+=e.length;}const p=Pl(s,u);for(let e=0;e<p.length;e+=3)t.indexArray.emplaceBack(a+p[e],a+p[e+1],a+p[e+2]);if(p.length>0&&i&&n){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,r=n.addVertices(c,h);n.addTriangles(p,r,e);const o=d.length;if(o>0){for(let a=0;a<o-1;a++)n.addRenderableRing(i.index,d[a]+r,d[a+1]-d[a],e,t,i.featureInfo);n.addRenderableRing(i.index,d[o-1]+r,c.length-d[o-1],e,t,i.featureInfo);}}o.vertexLength+=e,o.primitiveLength+=p.length/3;}return [r,o]}}qa(bh,"FillBucket",{omit:["layers","patternFeatures"]});const wh=Vu([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Eh=Vu([{name:"a_z_offset_width",components:4,type:"Float32"}],4),Ah=Vu([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),Ih=Vu([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:Th}=wh,Mh=Vu([{name:"a_packed",components:3,type:"Float32"}]),{members:Sh}=Mh,zh=Vu([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:Rh}=zh;class Ph{constructor(e,t,i,n,r){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r;e.pos<t;){const t=e.readVarint();if(8===t)this.id=e.readVarint();else if(18===t){const t=e.readVarint()+e.pos;for(;e.pos<t;){const t=n[e.readVarint()],i=r[e.readVarint()];this.properties[t]=i;}}else 24===t?this.type=e.readVarint():34===t?(this._geometry=e.pos,e.skip(t)):e.skip(t);}}loadGeometry(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let n,r=1,o=0,a=0,s=0;for(;e.pos<t;){if(o<=0){const t=e.readVarint();if(r=7&t,o=t>>3,0===o)continue}if(o--,1===r)a+=e.readSVarint(),s+=e.readSVarint(),n&&i.push(n),n=[new Pe(a,s)];else if(2===r)a+=e.readSVarint(),s+=e.readSVarint(),n&&n.push(new Pe(a,s));else {if(7!==r)throw new Error(`unknown command ${r}`);n&&n.push(n[0].clone());}}return n&&i.push(n),i}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;for(;e.pos<t;){if(n<=0){const t=e.readVarint();if(i=7&t,n=t>>3,0===n)continue}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),r<a&&(a=r),r>s&&(s=r),o<l&&(l=o),o>u&&(u=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return [a,l,s,u]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,a=this.loadGeometry();function s(e){return [360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(s)}let u;if(1===this.type){const e=[];for(const t of a)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};}else if(2===this.type){const e=a.map(l);u=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=function(e){const t=e.length;if(t<=1)return [e];const i=[];let n,r;for(let o=0;o<t;o++){const t=Dh(e[o]);0!==t&&(void 0===r&&(r=t<0),r===t<0?(n&&i.push(n),n=[e[o]]):n&&n.push(e[o]));}return n&&i.push(n),i}(a),t=[];for(const i of e)t.push(i.map(l));u=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};}}const c={type:"Feature",geometry:u,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function Dh(e){let t=0;for(let i,n,r=0,o=e.length,a=o-1;r<o;a=r++)i=e[r],n=e[a],t+=(n.x-i.x)*(i.y+n.y);return t}Ph.types=["Unknown","Point","LineString","Polygon"];class Ch{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],void 0===t&&(t=e.length);e.pos<t;){const t=e.readVarint();10===t?this.name=e.readString():18===t?(this._features.push(e.pos),e.skip(t)):26===t?this._keys.push(e.readString()):34===t?this._values.push(Fh(e)):40===t?this.extent=e.readVarint():120===t?this.version=e.readVarint():e.skip(t);}this.length=this._features.length;}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Ph(this._pbf,t,this.extent,this._keys,this._values)}}function Fh(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint();t=10===i?e.readString():21===i?e.readFloat():25===i?e.readDouble():32===i?e.readVarint(!0):40===i?e.readVarint():48===i?e.readSVarint():56===i?e.readBoolean():(e.skip(i),null);}if(null==t)throw new Error("unknown feature value");return t}class Oh{constructor(e,t=e.length){const i=Object.create(null);for(;e.pos<t;){const t=e.readVarint();if(26===t){const t=new Ch(e,e.readVarint()+e.pos);t.length&&(i[t.name]=t);}else e.skip(t);}this.layers=i;}}function Lh(e,t){for(let i=0;i<e.length;i++)if(Wh(t,e[i]))return !0;for(let i=0;i<t.length;i++)if(Wh(e,t[i]))return !0;return !!kh(e,t)}function Bh(e,t,i){return !!Wh(e,t)||!!Hh(t,e,i)}function Nh(e,t){if(1===e.length)return Zh(t,e[0]);for(let i=0;i<t.length;i++){const n=t[i];for(let t=0;t<n.length;t++)if(Wh(e,n[t]))return !0}for(let i=0;i<e.length;i++)if(Zh(t,e[i]))return !0;for(let i=0;i<t.length;i++)if(kh(e,t[i]))return !0;return !1}function Vh(e,t,i){if(e.length>1){if(kh(e,t))return !0;for(let n=0;n<t.length;n++)if(Hh(t[n],e,i))return !0}for(let n=0;n<e.length;n++)if(Hh(e[n],t,i))return !0;return !1}function kh(e,t){if(0===e.length||0===t.length)return !1;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)if(Uh(n,r,t[e],t[e+1]))return !0}return !1}function Uh(e,t,i,n){return gt(e,i,n)!==gt(t,i,n)&&gt(e,t,i)!==gt(e,t,n)}function Gh(e,t,i){return (e.x-i.x)*(t.y-i.y)-(e.y-i.y)*(t.x-i.x)}function jh(e,t,i,n){const r=Gh(e,t,n),o=Gh(e,t,i);if(Math.sign(r)===Math.sign(o))return;const a=Gh(i,n,e),s=a+o-r;return Math.sign(a)!==Math.sign(s)?[a/(a-s),o/(o-r)]:void 0}function Hh(e,t,i){const n=i*i;if(1===t.length)return e.distSqr(t[0])<n;for(let i=1;i<t.length;i++)if($h(e,t[i-1],t[i])<n)return !0;return !1}function $h(e,t,i){const n=t.distSqr(i);if(0===n)return e.distSqr(t);const r=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;return e.distSqr(r<0?t:r>1?i:i.sub(t)._mult(r)._add(t))}function Zh(e,t){let i,n,r,o=!1;for(let a=0;a<e.length;a++){i=e[a];for(let e=0,a=i.length-1;e<i.length;a=e++)n=i[e],r=i[a],n.y>t.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o);}return o}function Wh(e,t){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){const o=e[n],a=e[r];o.y>t.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(i=!i);}return i}function qh(e,t,i,n,r){for(const o of e)if(t<=o.x&&i<=o.y&&n>=o.x&&r>=o.y)return !0;const o=[new Pe(t,i),new Pe(t,r),new Pe(n,r),new Pe(n,i)];if(e.length>2)for(const t of o)if(Wh(e,t))return !0;for(let t=0;t<e.length-1;t++)if(Xh(e[t],e[t+1],o))return !0;return !1}function Xh(e,t,i){const n=i[0],r=i[2];if(e.x<n.x&&t.x<n.x||e.x>r.x&&t.x>r.x||e.y<n.y&&t.y<n.y||e.y>r.y&&t.y>r.y)return !1;const o=gt(e,t,i[0]);return o!==gt(e,t,i[1])||o!==gt(e,t,i[2])||o!==gt(e,t,i[3])}function Yh(e,t,i,n,r,o){let a=t.y-e.y,s=e.x-t.x;if(o=o||0){const e=a*a+s*s;if(0===e)return !0;const t=Math.sqrt(e);a/=t,s/=t;}return !((i.x-e.x)*a+(i.y-e.y)*s-o<0||(n.x-e.x)*a+(n.y-e.y)*s-o<0||(r.x-e.x)*a+(r.y-e.y)*s-o<0)}function Jh(e,t,i,n,r,o,a){return !(Yh(e,t,n,r,o,a)||Yh(t,i,n,r,o,a)||Yh(i,e,n,r,o,a)||Yh(n,r,e,t,i,a)||Yh(r,o,e,t,i,a)||Yh(o,n,e,t,i,a))}class Kh extends Pe{constructor(e,t,i){super(e,t),this.z=i;}}class Qh extends Kh{constructor(e,t,i,n){super(e,t,i),this.w=n;}}function ed(e,t,i,n){const r="x"===i?"y":"x",o=(n-e[i])/(t[i]-e[i]);e[r]=Math.round(e[r]+(t[r]-e[r])*o),e[i]=n,Object.hasOwn(e,"z")&&(e.z=dn(e.z,t.z,o)),Object.hasOwn(e,"w")&&(e.w=dn(e.w,t.w,o));}function td(e,t,i,n){const r=i,o=n;for(const i of ["x","y"]){let n=e,a=t;n[i]>=a[i]&&(n=t,a=e),n[i]<r&&a[i]>r&&ed(n,a,i,r),n[i]<o&&a[i]>o&&ed(a,n,i,o);}}function id(e,t,i,n,r,o){const a=[];for(let s=0;s<e.length;s++){const l=e[s];let u;const c=a.length;let h=0;for(let e=0;e<l.length-1;e++){let c=l[e],d=l[e+1],f=0;const p=h;let _,m;o&&(f=Math.hypot(d.x-c.x,d.y-c.y),h+=f,_=c,m=d),c.x<t&&d.x<t||(c.x<t?c=new Pe(t,c.y+(t-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x<t&&(d=new Pe(t,c.y+(t-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y<i&&d.y<i||(c.y<i?c=new Pe(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round():d.y<i&&(d=new Pe(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round()),c.x>=n&&d.x>=n||(c.x>=n?c=new Pe(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x>=n&&(d=new Pe(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y>=r&&d.y>=r||(c.y>=r?c=new Pe(c.x+(r-c.y)/(d.y-c.y)*(d.x-c.x),r)._round():d.y>=r&&(d=new Pe(c.x+(r-c.y)/(d.y-c.y)*(d.x-c.x),r)._round()),u&&c.equals(u.at(-1))||(u=[c],a.push(u),o&&o.push({progress:{min:p+rd(_,m,c)*f,max:1},parentIndex:s,prevPoint:_,nextPoint:m})),u.push(d),o&&(o.at(-1).progress.max=p+rd(_,m,d)*f,o.at(-1).nextPoint=m)))));}if(o&&h>0)for(let e=c;e<a.length;e++)o[e].progress.min/=h,o[e].progress.max/=h;}return a}function nd(e,t,i,n,r){if(e.length<2)return void n.push(e);const o=[];for(;t.valid();){const[i,n]=t.get();for(let t=0;t<e.length-1;t++){const r=e[t],a=e[t+1],s=jh(r,a,i,n);if(s){const[e]=s,i=new Pe(dn(r.x,a.x,e),dn(r.y,a.y,e));o.push({t:t+e,distance:0,point:i});}}t.next();}if(0===o.length)return void n.push(e);o.sort((e,t)=>e.t-t.t);let a=0,s=0,l=[];for(n.push(l);a!==e.length;){if(s===o.length){for(;a!==e.length;)0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++;break}o[s].t<=a?(0!==l.length&&l.at(-1).equals(o[s].point)||l.push(o[s].point),Math.trunc(o[s].t),s++):(0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++);}}function rd(e,t,i){return e.x!==t.x?(i.x-e.x)/(t.x-e.x):e.y!==t.y?(i.y-e.y)/(t.y-e.y):0}function od(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function ad(e,t,i){const{width:n,height:r}=t;n===e.width&&r===e.height||(sd(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,r)},i,null),e.width=n,e.height=r,e.data=t.data);}function sd(e,t,i,n,r,o,a,s){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,u=t.data,c=4===o&&s;for(let s=0;s<r.height;s++){const h=((i.y+s)*e.width+i.x)*o,d=((n.y+s)*t.width+n.x)*o;if(c)for(let e=0;e<r.width;e++){const t=h+e*o+3,i=d+e*o;u[i+0]=255,u[i+1]=255,u[i+2]=255,u[i+3]=l[t];}else if(a)for(let e=0;e<r.width;e++){const t=h+e*o,i=d+e*o,n=new pn(l[t+0]/255,l[t+1]/255,l[t+2]/255,l[t+3]).toNonPremultipliedRenderColor(a).toArray();u[i+0]=n[0],u[i+1]=n[1],u[i+2]=n[2],u[i+3]=n[3];}else for(let e=0;e<r.width*o;e++)u[d+e]=l[h+e];}return t}class ld{constructor(e,t){od(this,e,1,t);}resize(e){ad(this,new ld(e),1);}clone(){return new ld({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r){sd(e,t,i,n,r,1,null);}}class ud{constructor(e,t){od(this,e,4,t);}resize(e){ad(this,new ud(e),4);}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e;}clone(){return new ud({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r,o,a){sd(e,t,i,n,r,4,o,a);}}class cd{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t;}}qa(ld,"AlphaImage"),qa(ud,"RGBAImage");class hd{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new ld({width:e,height:t}),this.positions={},this.uploaded=!1;}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=lt(this.nextRow);this.image.resize({width:e,height:t});}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const n=[];let r=e.length%2==1?-e.at(-1)*i:0,o=e[0]*i,a=!0;n.push({left:r,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t<e.length;t++){a=!a;const l=e[t];r=s*i,s+=l,o=s*i,n.push({left:r,right:o,isDash:a,zeroLength:0===l});}return n}addRoundDash(e,t,i){const n=t/2;for(let t=-i;t<=i;t++){const r=this.width*(this.nextRow+i+t);let o=0,a=e[o];for(let s=0;s<this.width;s++){s/a.right>1&&(a=e[++o]);const l=Math.abs(s-a.left),u=Math.abs(s-a.right),c=Math.min(l,u);let h;const d=t/i*(n+1);if(a.isDash){const e=n-Math.abs(d);h=Math.sqrt(c*c+e*e);}else h=n-Math.sqrt(c*c+d*d);this.image.data[r+s]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1));}const i=e[0],n=e.at(-1);i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let i=0;i<this.width;i++){i/a.right>1&&(a=e[++o]);const n=Math.abs(i-a.left),s=Math.abs(i-a.right),l=Math.min(n,s);this.image.data[r+i]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128));}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const n="round"===t,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return mt("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t<e.length;t++)e[t]<0&&(mt("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),a+=e[t];if(0!==a){const i=this.width/a,o=this.getDashRanges(e,this.width,i);n?this.addRoundDash(o,i,r):this.addRegularDash(o,"square"===t?.5*i:0);}const s=this.nextRow+r;let l=0;if(0!==a){const e=this.width*s;for(let t=0;t<this.width;t++)this.image.data[e+t]>=128&&l++;}const u=Math.round(l/this.width*4095);this.nextRow+=o;const c=Math.floor(a),h={tl:[s,r|u<<4],br:[c,Math.round(65535*(a-c))]};return this.positions[i]=h,h}}qa(hd,"LineAtlas");const dd="3d_elevation_id",fd="level",pd=Ph.types,_d=Math.cos(Math.PI/180*37.5),md=Math.cos(Math.PI/180*5);class gd{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.terrainEnabled=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.borderGradients={},this.layers.forEach(e=>{this.gradients[e.id]={},this.borderGradients[e.id]={};}),this.layoutVertexArray=new Xu,this.layoutVertexArray2=new Yu,this.patternVertexArray=new Yu,this.indexArray=new uc,this.programConfigurations=new ph(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Uc,this.sourceLayerName=e.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new ic,this.elevationIdColVertexArray=new Yu,this.elevationGroundScaleVertexArray=new Hu,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.showElevationIdDebug=t.showElevationIdDebug,this.terrainEnabled=t.terrainEnabled,this.hasPattern=ru("line",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Au(i);const o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else {const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&t?"none":"offset","offset"===this.elevationType&&"none"===o&&mt(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===o;}const a=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==a;const s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Fu(o,e);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,d={id:a,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Cu(o,i,n),patterns:{},sortKey:h};s.push(d);}r&&s.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:u}=t,c=this.addConstantDashes(l);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:a}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const e=ou("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,r,o,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures,t.elevationParams,t.crossSourceElevationEnabled);u.insert(e[o].feature,r,o,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this),this.hdExt&&this.hdExt.endPopulate();}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else {const t=r.value,i=n.value;if(!i)continue;e.addDash(i,t);}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let a,s;if("constant"===r.kind){if(a=r.value,!a)continue}else a=r.evaluate({zoom:i},e);s="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(a,s),e.patterns[n.id]=[t.getKey(a,s)];}}update(e,t,i,n,r,o,a,s,l){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,l);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}addFeatures(e,t,i,n,r,o){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,o,e.elevationFeatures,e.elevationParams,e.crossSourceElevationEnabled);this.hdExt&&(this.hdExt.buildFrcSegments(this),this.hdExt.endPopulate());}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,Sh)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Rh)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Eh.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,Ah.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Ih.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Th),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e,t){let i,n;if(t&&t>0?(i=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,i)&&Object.hasOwn(e.properties,n))return {start:+e.properties[i],end:+e.properties[n]}}addFeature(e,t,i,n,r,o,a,s,l,u){const c=this.layers[0].layout,h=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,d=this.indexArray.length,f=c.get("line-join").evaluate(e,{}),p=c.get("line-cap").evaluate(e,{}),_=c.get("line-miter-limit"),m=c.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const g=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=c.get("line-z-offset").value;const y=this.layers[0].paint,x=y.get("line-width").value;"constant"!==x.kind&&!1===x.isLineProgressConstant&&(this.variableWidthValue=x);const v=y.get("line-emissive-strength").value;if("constant"!==v.kind&&!1===v.isLineProgressConstant&&(this.variableEmissiveStrengthValue=v),this.isSeaLevelReference){const e=c.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e);}if(null==this.hdExt||!this.hdExt.handleFeature(e,t,n,s,l,!!u,f,p,_,m,this))for(let i=0;i<t.length;i++)this.addLine(t[i],e,n,f,p,_,m,void 0,g&&i>0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n,a,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,d,this.indexArray.length,h);}fillNonElevatedRoadSegment(e){for(let t=Math.max(e,this.zOffsetVertexArray.length);t<this.layoutVertexArray.length;t++)this.zOffsetVertexArray.emplaceBack(0,0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0);}addLine(e,t,i,n,r,o,a,s,l){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=l?this.lineFeatureClips(t,l):this.lineClips;const u="none"===n;this.patternJoinNone=this.hasPattern&&u,this.currentLineJoinType=n,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const c=s&&s.progress.min>0,h=s&&s.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},n=1;if(s){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return {min:zt(e.min,t,i),max:zt(e.max,t,i)}}(s.progress,{min:0,max:1},i),e>0&&(n=(i.max-i.min)/e);}const r=+t.properties.mapbox_clip_feature_len,o=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(r)||Number.isNaN(o)){for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);const t=this.totalDistance/(i.max-i.min);this.totalFeatureLength=Number.isFinite(t)?t:0,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance);}else this.totalFeatureLength=r,this.distance=o*n,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance();}const d="Polygon"===pd[t.type];let f=e.length;for(;f>=2&&e[f-1].equals(e[f-2]);)f--;let p=0;for(;p<f-1&&e[p].equals(e[p+1]);)p++;if(f<(d?3:2))return;"bevel"===n&&(o=1.05);const _=this.segments.prepareSegment(10*f,this.layoutVertexArray,this.indexArray);let m,g,y,x,v,b,w,E;s&&s.prevDir&&(b=s.prevDir.perp()),s&&s.nextDir&&(w=s.nextDir.perp()),this.e1=this.e2=-1,d&&(m=e[f-2],v=e[p].sub(m)._unit()._perp());for(let t=p;t<f;t++){if(y=t===f-1?d?e[p+1]:void 0:e[t+1],y&&e[t].equals(y))continue;v&&(x=v),m&&(g=m),m=e[t],E=this.evaluateLineProgressFeatures(g?g.dist(m):0),v=y?y.sub(m)._unit()._perp():x,x=x||v;const i=g&&y;let s=i?n:d||u?"butt":r;const l=x.x*v.x+x.y*v.y;if(u){const e=function(e){if(e.patternJoinNone){const t=e.segmentPoints.length/2,i=e.lineSoFar-e.segmentStart;for(let n=0;n<t;++n){const t=e.segmentPoints[2*n+1],r=Math.round(e.segmentPoints[2*n])+.5+.25*t;e.patternVertexArray.emplaceBack(r,i,e.segmentStart),e.patternVertexArray.emplaceBack(r,i,e.segmentStart);}e.segmentPoints.length=0;}e.e1=e.e2=-1;};if(i&&l<md){this.updateDistance(g,m),this.addCurrentVertex(m,x,1,1,_,E),e(this),this.addCurrentVertex(m,v,-1,-1,_,E);continue}if(g){if(!y){this.updateDistance(g,m),this.addCurrentVertex(m,x,1,1,_,E),e(this);continue}s="miter";}}let A=x.add(v);0===A.x&&0===A.y||A._unit();const I=A.x*v.x+A.y*v.y,T=0!==I?1/I:1/0,M=2*Math.sqrt(2-2*I),S=I<_d&&g&&y,z=x.x*v.y-x.y*v.x>0,R=this.overscaling<=16?122880/(512*this.overscaling):0;if(i&&"round"===s)if(T<a)s="miter";else if(T<=2){const e=yd(m,-10,8202);s="offset"===this.elevationType&&(e||this.hasCrossSlope)?"miter":"fakeround";}if("miter"===s&&T>o&&(s="bevel"),"bevel"===s&&(T>2&&(s="flipbevel"),T<o&&(s="miter")),g&&!("miter"===s&&S)&&this.updateDistance(g,m),"miter"===s)if(S){const e=m.dist(g);if(e>2*R){const t=m.sub(m.sub(g)._mult(R/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,x,0,0,_,E),g=t;}this.updateDistance(g,m),A._mult(T),this.addCurrentVertex(m,A,0,0,_,E);const t=m.dist(y);if(t>2*R){const e=m.add(y.sub(m)._mult(R/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,_,E),m=e;}}else A._mult(T),this.addCurrentVertex(m,A,0,0,_,E);else if("flipbevel"===s){if(T>100)A=v.mult(-1);else {const e=T*x.add(v).mag()/x.sub(v).mag();A._perp()._mult(e*(z?-1:1));}this.addCurrentVertex(m,A,0,0,_,E),this.addCurrentVertex(m,A.mult(-1),0,0,_,E);}else if("bevel"===s||"fakeround"===s){const e=m.dist(g);let t=1;if("offset"===this.elevationType&&"bevel"===s&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=E&&g&&y){const i=4*R;e<i&&(t=Math.max(0,e/i));}null!=E&&g&&this.addCurrentVertex(m,w||x,-t,-t,_,E);const i=e<=1*R&&"bevel"!==s,n=i?1:T,r=A.mult(z?1:-1);r._mult(n);const o=v.mult(z?-1:1),a=x.mult(z?-1:1),u=this.evaluateLineProgressFeatures(this.distance);if(null==E&&(this.addHalfVertex(m,r.x,r.y,!1,!z,0,_,u),i||this.addHalfVertex(m,r.x+2*a.x,r.y+2*a.y,!1,z,0,_,u)),"fakeround"===s){const e=Math.round(180*M/Math.PI/20);this.addHalfVertex(m,a.x,a.y,!1,z,0,_,u);for(let t=0;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+l*(l*(3.55645-1.43519*l)-3.2452))*e*e+(.848013+l*(.215638*l-1.06021)));}const n=o.sub(a)._mult(i)._add(a)._unit();this.addHalfVertex(m,n.x,n.y,!1,z,0,_,u);}this.addHalfVertex(m,o.x,o.y,!1,z,0,_,u);}i||null!=E||this.addHalfVertex(m,r.x+2*o.x,r.y+2*o.y,!1,z,0,_,u),null!=E&&y&&this.addCurrentVertex(m,b||v,t,t,_,E);}else if("butt"===s)this.addCurrentVertex(m,A,0,0,_,E);else if("square"===s){if(!g){const e=c?0:-1;this.addCurrentVertex(m,A,e,e,_,E);}if(this.addCurrentVertex(m,A,0,0,_,E),g){const e=h?0:1;this.addCurrentVertex(m,A,e,e,_,E);}}else if("round"===s){if(g){const e=!i&&w?w:x;this.addCurrentVertex(m,e,0,0,_,E),!i&&h||this.addCurrentVertex(m,e,1,1,_,E,!0);}if(y){const e=!i&&b?b:v;!i&&c||this.addCurrentVertex(m,e,-1,-1,_,E,!0),this.addCurrentVertex(m,e,0,0,_,E);}}}}addVerticesTo(e,t,i,n,r,o,a,s,l,u){const c=(t.w-e.w)/this.tessellationStep|0;let h=0;const d=this.scaledDistance;if(c>1){this.lineSoFar=e.w;const i=(t.x-e.x)/c,n=(t.y-e.y)/c,r=(t.z-e.z)/c,o=(t.w-e.w)/c,a=t.x-e.x,s=t.y-e.y,d=Math.sqrt(a*a+s*s);if(0===d)return;const f=-s/d,p=a/d,_=f,m=p,g=-f,y=-p;for(let t=1;t<c;++t){e.x+=i,e.y+=n,e.z+=r,this.lineSoFar+=o,h+=o;const t=this.evaluateLineProgressFeatures(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(e,_,m,u,!1,0,l,t),this.addHalfVertex(e,g,y,u,!0,0,l,t);}}this.lineSoFar=t.w,this.scaledDistance=d;const f=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,i,n,u,!1,a,l,f),this.addHalfVertex(t,r,o,u,!0,-s,l,f);}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&!this.variableEmissiveStrengthValue&&"offset"!==this.elevationType)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):mt(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,t*=.5);let i=0;this.variableEmissiveStrengthValue&&"constant"!==this.variableEmissiveStrengthValue.kind&&(i=this.variableEmissiveStrengthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const n=this.evaluateElevationGroundScale();return "offset"!==this.elevationType?{zOffset:0,variableWidth:t,elevationGroundScale:n,variableEmissiveStrength:i}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:t,elevationGroundScale:n,variableEmissiveStrength:i}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t,elevationGroundScale:n,variableEmissiveStrength:i}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?"constant"===this.elevationGroundScaleValue.kind?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,t,i,n,r,o,a=!1){const s=t.x+t.y*i,l=t.y-t.x*i,u=t.y*n-t.x,c=-t.y-t.x*n;if(null!=o){const t="offset"===this.elevationType,h="offset"===this.elevationType?2:10,d=-h,f=Sr+h,p=o.zOffset,_=new Qh(e.x,e.y,p,this.lineSoFar),m=!!t&&yd(e,d,f),g=this.lineSoFar,y=this.distance;if(this.currentVertex)if(m){const t=this.currentVertexIsOutside,o=this.currentVertex,h=new Qh(e.x,e.y,p,this.lineSoFar);if(td(o,h,d,f),!yd(h,d,f)){if(t){this.e1=this.e2=-1,this.distance-=o.dist(_),this.lineSoFar=o.w;const e=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,s,l,a,!1,i,r,e),this.addHalfVertex(o,u,c,a,!0,-n,r,e),this.prevDistance=this.distance;}this.distance=this.prevDistance+o.dist(h),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,h,s,l,u,c,i,n,r,a),this.distance=y,this.scaledDistance=this.distance/this.totalDistance;}}else {const e=this.currentVertex;if(this.currentVertexIsOutside){td(e,_,d,f),this.e1=this.e2=-1,this.distance-=e.dist(_),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e.w;const t=this.evaluateLineProgressFeatures(e.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(e,s,l,a,!1,i,r,t),this.addHalfVertex(e,u,c,a,!0,-n,r,t),this.prevDistance=this.distance,this.distance=y,this.scaledDistance=this.distance/this.totalDistance;}this.addVerticesTo(e,_,s,l,u,c,i,n,r,a);}else m||(this.addHalfVertex(e,s,l,a,!1,i,r,o),this.addHalfVertex(e,u,c,a,!0,-n,r,o));this.currentVertex=_,this.currentVertexIsOutside=m,this.lineSoFar=g;}else this.addHalfVertex(e,s,l,a,!1,i,r,o),this.addHalfVertex(e,u,c,a,!0,-n,r,o);}addHalfVertex({x:e,y:t},i,n,r,o,a,s,l){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),o||this.segmentPoints.push(this.lineSoFar-this.segmentStart,a)),this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const e=dn(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,e);}const u=s.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),s.primitiveLength++),o?this.e2=u:this.e1=u,null!=l&&(this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth,l.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e);}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance();}}function yd(e,t,i){return e.x<t||e.x>i||e.y<t||e.y>i}qa(gd,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const xd=Vu([{name:"a_pos",components:2,type:"Int16"}],4),vd=Vu([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),bd=Vu([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wd{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Uu,this.indexArray=new uc,this.segments=new Uc,this.programConfigurations=new ph(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){const r=this.layers[0],o=[];let a=null;"circle"===r.type&&(a=r.layout.get("circle-sort-key"));for(const{feature:r,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Fu(r,e);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const h=a?a.evaluate(c,{},i):void 0,d={id:s,properties:r.properties,type:r.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Cu(r,i,n),patterns:{},sortKey:h};o.push(d);}a&&o.sort((e,t)=>e.sortKey-t.sortKey);let s=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Qu,s=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:a}=n,l=e[o].feature;this.addFeature(n,r,o,t.availableImages,i,s,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,r,o,a,this.index);}this.hdExt&&this.hdExt.finalize();}update(e,t,i,n,r,o,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,bd.members)),this.hdExt&&this.hdExt.upload(e)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.hdExt&&this.hdExt.destroy());}addFeature(e,t,i,n,r,o,a,s){this.hdExt&&this.hdExt.beginFeature(e,s,r);for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=Sr||n<0||n>=Sr)continue;if(o){const e=o.projectTilePoint(i,n,r),t=o.upVector(r,i,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;this.addCircleVertex(i,n,-1,-1),this.addCircleVertex(i,n,1,-1),this.addCircleVertex(i,n,1,1),this.addCircleVertex(i,n,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(i,n),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},n,r,a,void 0,this.worldview);}addCircleVertex(e,t,i,n){this.layoutVertexArray.emplaceBack(2*e+(i+1)/2,2*t+(n+1)/2);}addGlobeExtVertex(e,t){const i=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*i,t[1]*i,t[2]*i);}}qa(wd,"CircleBucket",{omit:["layers"]});const Ed=Vu([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ad=Vu([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Id=Vu([{name:"a_projected_pos",components:4,type:"Float32"}],4);Vu([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Td=Vu([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Md=Vu([{name:"a_feature_index",components:1,type:"Float32"}],4),Sd=Vu([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),zd=Vu([{name:"a_texb",components:2,type:"Uint16"}]),Rd=Vu([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Pd=Vu([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Vu([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Dd=Vu([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Cd=Vu([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Vu([{name:"triangle",components:3,type:"Uint16"}]),Vu([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Vu([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Vu([{type:"Float32",name:"offsetX"}]),Vu([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Fd=new Float32Array(1),Od=new Uint32Array(Fd.buffer);function Ld(e){return Fd[0]=e,Od[0]}const Bd=class e{static getBlockIndices(t){let i=e._blockIndicesTemplate;if(!i){i=e._blockIndicesTemplate=new Uint32Array(t);for(let e=0;e<t;e++)i[e]=e;}return i}constructor(e,t,i,n){this.batchIndex=t,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=i,this.totalBytes=4*this.propsDwords,this.headerData=n,this.propertiesData=new Float32Array(this.propsDwords),this._headerDirty=!0,this._propsDirtyMin=-1,this._propsDirtyMax=-1,this._blockIndicesDirty=!0,e&&this._initBuffers(e);}_initBuffers(t){const i=t.gl;if(this.totalBytes>t.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${t.maxUniformBlockSize}`);if(this.headerBuffer=i.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferData(i.UNIFORM_BUFFER,e.HEADER_BYTES,i.DYNAMIC_DRAW),this.propertiesBuffer=i.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),this.blockIndicesBuffer=i.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),i.bindBuffer(i.UNIFORM_BUFFER,null);}markHeaderDirty(){this._headerDirty=!0;}writeDataDrivenBlock(e,t){const i=this.headerData,n=4*i[2];if(0===n)return;const r=t*n;if(r+n>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${t} exceeds propertiesData capacity`);const o=i[0];for(let t=0;t<9;t++)o&1<<t&&this._copyFromFlat(r+4*i[3+t],t,e);(-1===this._propsDirtyMin||r<this._propsDirtyMin)&&(this._propsDirtyMin=r);const a=r+n;a>this._propsDirtyMax&&(this._propsDirtyMax=a);}rightSizeForTransfer(){const e=-1===this._propsDirtyMax?0:this._propsDirtyMax;e<this.propertiesData.length&&(this.propertiesData=this.propertiesData.slice(0,e));}_copyFromFlat(t,i,n){let r=4;(i<2||8===i)&&(r=this.headerData[1]>>>i&1?8:4);const o=e.EVAL_FLAT_OFFSETS[i];this.propertiesData.set(n.subarray(o,o+r),t);}upload(t){this.context||(this.context=t);const i=t.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(t);let n=!1;if(this._headerDirty&&(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.headerData),this._headerDirty=!1,n=!0),-1!==this._propsDirtyMin){const e=this._propsDirtyMin,t=this._propsDirtyMax;i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,4*e,this.propertiesData,e,t-e),this._propsDirtyMin=-1,this._propsDirtyMax=-1,n=!0;}this._blockIndicesDirty&&(i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,e.getBlockIndices(this.propsDwords)),this._blockIndicesDirty=!1,n=!0),n&&i.bindBuffer(i.UNIFORM_BUFFER,null);}bind(e,t){const i=e.gl,n=(e,n,r)=>{if(!n)return;const o=i.getUniformBlockIndex(t,e);o!==i.INVALID_INDEX&&(i.uniformBlockBinding(t,o,r),i.bindBufferBase(i.UNIFORM_BUFFER,r,n));},r=3*this.batchIndex;n("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,r),n("SymbolPaintPropertiesUniform",this.propertiesBuffer,r+1),n("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,r+2);}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null);}}};Bd.HEADER_DWORDS=16,Bd.HEADER_BYTES=64,Bd.EVAL_FLAT_OFFSETS=[0,8,16,20,24,28,32,36,40],Bd.EVAL_FLAT_TOTAL=48,Bd._blockIndicesTemplate=null;let Nd=Bd;function Vd(e,t,i,n,r,o,a,s){return !!e&&("constant"===e.kind?"none"===e.value:"none"===e.evaluate({zoom:0,brightness:o,worldview:s},t,i,r,n,a))}function kd(e){if(!(e instanceof Js))return !1;const t=e.value;return ("source"===t.kind||"composite"===t.kind)&&t.isStateDependent}qa(Nd,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});const Ud=["icon","text"].map(e=>[`${e}-color`,`${e}-halo-color`,`${e}-opacity`,`${e}-halo-width`,`${e}-halo-blur`,`${e}-emissive-strength`,`${e}-occlusion-opacity`,"symbol-z-offset",`${e}-translate`]),Gd=new Float32Array(Nd.EVAL_FLAT_TOTAL),jd=[0,0],Hd=new WeakMap;class $d{constructor(e,t,i,n,r="",o,a){this.layer=e,this.zoom=t,this.lut=i,this.isText=n,this.worldview=r,this.maxUniformBufferBindings=o||24,this.uboSizeDwords=a||4096,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.allFormattedSections=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.ubos=[],this.featureCount=0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.cachedConstantPaint=null,this.activeAppearanceByVtIndex=null,this.zoomDependency=new Uint8Array(9),this.sharedZoomRanges=new Float32Array(18),this._zoomRangeScratch=new Float32Array(2),this._floorZoom=Math.floor(this.zoom),this.header=new Uint32Array(Nd.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=0===this.header[0];const s=4*this.header[2];this.maxFeaturesPerBatch=0===s?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/s);}updateHeader(){const e=this.layer.paint;let t=0,i=0,n=0,r=0,o=!0;const a=this._floorZoom,s=Ud[+this.isText];for(let l=0;l<9;l++){const u=s[l],c=l<2,h=e.get(u),d=!(!h||"function"!=typeof h.isConstant||h.isConstant()),f=this._appearancesHavePaintProperties(u);if(!d&&!f){const e=this._layerUnevaluated(u);e&&e.expression&&"camera"===e.expression.kind&&(n|=1<<l);continue}t|=1<<l;const p=this._collectZoomSignatures(u,a),_=p.hasZoom,m=p.differs,g=8===l;this.zoomDependency[l]=m?2:_?1:0;const y=m||g&&_;y&&(i|=1<<l);const x=h&&h.value;x&&!1===x.isLightConstant&&(o=!1),this.header[3+l]=r,r+=y?2:1,_&&!m&&p.representative&&(this._computeZoomRange(p.representative,a,this.sharedZoomRanges,2*l),c&&(this.header[12+2*l]=Ld(this.sharedZoomRanges[2*l]),this.header[12+2*l+1]=Ld(this.sharedZoomRanges[2*l+1])));}this.header[0]=t,this.header[1]=i,this.header[2]=r,this.isLightConstant=o,this.cameraMask=n;}_recomputeSharedRanges(){const e=this._floorZoom,t=Ud[+this.isText];let i=0,n=!1;for(let r=0;r<9;r++){const o=t[r],a=this.zoomDependency[r];if(this.header[0]&1<<r){if(0!==a&&2!==a){const t=this._collectZoomSignatures(o,e);t.representative&&(this._computeZoomRange(t.representative,e,this.sharedZoomRanges,2*r),r<2&&(this.header[12+2*r]=Ld(this.sharedZoomRanges[2*r]),this.header[12+2*r+1]=Ld(this.sharedZoomRanges[2*r+1]),n=!0));}}else {const e=this._layerUnevaluated(o);e&&e.expression&&"camera"===e.expression.kind&&(i|=1<<r);}}if(this.cameraMask=i,n)for(const e of this.ubos)e.markHeaderDirty();}_collectZoomSignatures(e,t){let i=!1,n=!1,r=null,o=0,a=0;const s=e=>{if(!e)return;this._computeZoomRange(e,t,this._zoomRangeScratch,0);const s=this._zoomRangeScratch[0],l=this._zoomRangeScratch[1];i?s===o&&l===a||(n=!0):(i=!0,o=s,a=l,r=e);};s(this._zoomExprOf(this._layerUnevaluated(e)));for(const t of this.layer.getAppearances()||[])t.hasPaintProperty(e)&&s(this._zoomExprOf(t.getUnevaluatedPaintProperty(e)));return {hasZoom:i,differs:n,representative:r}}evaluateAllProperties(e,t,i,n,r,o,a){const s={brightness:r,worldview:this.worldview},l={feature:e,featureState:t,canonical:i,availableImages:n,params:new Hs(this.zoom,s),paramsNext:new Hs(this.zoom+1,s),formattedSection:o,activeAppearance:a},u=Ud[+this.isText];for(let e=0;e<9;e++){const t=u[e],i=e<2,n=8===e,r=this.zoomDependency[e],o=0!==r,a=2===r,s=Nd.EVAL_FLAT_OFFSETS[e],c=s+(i||n?4:2);i?this._evaluateColorValue(t,e,o,a,c,l,s):n?this._evaluateTranslateValue(t,e,o,a,c,l,s):this._evaluateFloatValue(t,e,o,a,c,l,s);}return Gd}_resolveProp(e,t,i=!1,n){const r=this.layer.paint,o=r.get(e),a=e,s=!(!t||!t.hasPaintProperty(a)),l=s?n&&o&&o.property.overrides&&o.property.overrides.hasOverride(n)?o:t.paintProperties.get(a):r.get(e);if(i||!l||"function"!=typeof l.isConstant||!l.isConstant())return l;const u=s?t.getUnevaluatedPaintProperty(a):this._layerUnevaluated(e);return this._unbakeCamera(l,u)}_unbakeCamera(e,t){const i=t&&t.expression;if(!i||"camera"!==i.kind)return e;let n=Hd.get(t);return n||(n=new Js(e.property,i,e.parameters,e.iconImageUseTheme),Hd.set(t,n)),n}_layerUnevaluated(e){const t=this.layer._transitionablePaint._values[e];return t&&t.value}_zoomExprOf(e){const t=e&&e.expression;return !t||"composite"!==t.kind&&"camera"!==t.kind?null:t}_evalAt(e,t,i){return e.property.evaluate(e.value,t,i.feature,i.featureState,i.canonical,i.availableImages,e.iconImageUseTheme,i.formattedSection)}_evaluateColorValue(e,t,i,n,r,o,a){const s=this._resolveProp(e,o.activeAppearance,!1,o.formattedSection);if(this._writePropertyZoomRange(t,i,n,s,r),!s)return Gd[a]=0,Gd[a+1]=0,Gd[a+2]=0,void(Gd[a+3]=1);const l=this._resolveProp(`${e}-use-theme`,o.activeAppearance,!0),u=Vd(l&&"string"!=typeof l?l.value:void 0,o.feature,o.featureState,o.availableImages,o.canonical,o.params.brightness,o.formattedSection,this.worldview)?null:this.lut,c=(s.isConstant()?s.constantOr(pn.transparent):this._evalAt(s,o.params,o)||pn.transparent).toNonPremultipliedRenderColor(u);if(Gd[a]=Gc(255*c.r,255*c.g),Gd[a+1]=Gc(255*c.b,255*c.a),i){const e=(this._evalAt(s,o.paramsNext,o)||pn.transparent).toNonPremultipliedRenderColor(u);Gd[a+2]=Gc(255*e.r,255*e.g),Gd[a+3]=Gc(255*e.b,255*e.a);}else Gd[a+2]=Gd[a],Gd[a+3]=Gd[a+1];}_computeZoomRange(e,t,i,n){let r=0,o=1;const a=!e||"composite"!==e.kind&&"camera"!==e.kind?null:e.zoomStops;if(a&&a.length>0)if(null==e.interpolationType){r=o=1;for(const e of a)if(e>t&&e<t+1){r=o=e-t;break}}else a[0]>t&&a[0]<t+1&&(r=a[0]-t);i[n]=r,i[n+1]=o;}_writeZoomRange(e,t){this._computeZoomRange(e&&e.value,this._floorZoom,Gd,t);}_writePropertyZoomRange(e,t,i,n,r){i?this._writeZoomRange(n,r):t?(Gd[r]=this.sharedZoomRanges[2*e],Gd[r+1]=this.sharedZoomRanges[2*e+1]):(Gd[r]=0,Gd[r+1]=0);}_evaluateFloatValue(e,t,i,n,r,o,a){const s=e.endsWith("opacity")?1:0,l=this._resolveProp(e,o.activeAppearance);this._writePropertyZoomRange(t,i,n,l,r);const u=(l?l.isConstant()?l.constantOr(s):this._evalAt(l,o.params,o):s)??s;if(Gd[a]=u,i){const e=this._evalAt(l,o.paramsNext,o);Gd[a+1]=e??s;}else Gd[a+1]=u;}_evaluateTranslateValue(e,t,i,n,r,o,a){const s=this._resolveProp(e,o.activeAppearance);this._writePropertyZoomRange(t,i,n,s,r);const l=!!s&&"function"==typeof s.isConstant&&!s.isConstant(),u=s?"function"!=typeof s.isConstant?s:l?this._evalAt(s,o.params,o):s.constantOr(jd):void 0;if(Gd[a]=u?u[0]:0,Gd[a+1]=u?u[1]:0,i){const e=l?this._evalAt(s,o.paramsNext,o):u;Gd[a+2]=e?e[0]:0,Gd[a+3]=e?e[1]:0;}else Gd[a+2]=Gd[a],Gd[a+3]=Gd[a+1];}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(t=>t.hasPaintProperty(e))}hasStateDependentPaint(e){const t=e.paint,i=Ud[+this.isText];for(const e of i)if(kd(t.get(e)))return !0;for(const t of e.getAppearances()||[])for(const e of i){const i=e;if(t.hasPaintProperty(i)&&kd(t.paintProperties.get(i)))return !0}return !1}hasPerFeatureTranslate(){return !!(256&this.header[0])}getCurrentBatchIndex(){return 0===this.maxFeaturesPerBatch?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(e,t){const i=this.isAllConstant?0:e;let n=Math.floor(i/this.maxFeaturesPerBatch),r=i%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(n)&&(n=0,r=0);const o=this.ubos[n];return !!o&&(o.writeDataDrivenBlock(t,r),!0)}_batchExceedsDeviceLimit(e){return 3*e+2>=this.maxUniformBufferBindings}_reevaluateAt(e,t,i,n,r,o){if(!t)return;const a=this.allFeatureVtIndices[e],s=t.feature(a);if(!s)return;const l=this.allFeatureIds[e],u=null!=l&&r[l]||{},c={type:s.type,id:l,properties:s.properties||{},geometry:[]},h=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(a):void 0,d=this.evaluateAllProperties(c,u,i,n,o,(this.allFormattedSections?this.allFormattedSections[e]:void 0)||void 0,h);this._writeFeatureBlock(e,d);}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let e=0;e<this.allFeatureVtIndices.length;e++){const t=this.allFeatureIds[e];if(null!=t){let i=this.featureVertexRangesFromId.get(t);i||this.featureVertexRangesFromId.set(t,i=[]),i.push(e);}const i=this.allFeatureVtIndices[e];let n=this.featureVertexRangesFromVtIndex.get(i);n||this.featureVertexRangesFromVtIndex.set(i,n=[]),n.push(e);}}}populateUBO(e,t,i,n,r,o){const a=e.id,s=this.header,l=this.evaluateAllProperties(e,{},i,n,r,o);let u,c;this.isAllConstant?(u=0,c=0===this.featureCount,c&&(this.featureCount=1)):(u=this.featureCount++,c=!0);let h=Math.floor(u/this.maxFeaturesPerBatch),d=u%this.maxFeaturesPerBatch;return c&&(this._batchExceedsDeviceLimit(h)?(mt(`Too many symbol features: batch ${h} requires binding points up to ${3*h+2}, device limit ${this.maxUniformBufferBindings}. Some features will render incorrectly.`),h=0,d=0):(this.ubos[h]||(this.ubos[h]=new Nd(null,h,this.uboSizeDwords,s)),this.ubos[h].writeDataDrivenBlock(l,d))),this.allFeatureVtIndices.push(t),this.allFeatureIds.push(a),this.allFormattedSections.push(o||null),d}updateFeatures(e,t,i,n,r,o,a){this.layer=t,this.cachedConstantUniforms=null,this._ensureRangeMaps();for(const t of e){const e=this.featureVertexRangesFromId.get(t);if(e)for(const t of e)this._reevaluateAt(t,i,n,r,o,a);}}updateDynamicExpressions(e,t,i,n,r,o){if(this.layer=e,this.cachedConstantUniforms=null,this._recomputeSharedRanges(),0!==this.header[0])for(let e=0;e<this.allFeatureVtIndices.length;e++)this._reevaluateAt(e,t,i,n,r,o);}updateFeaturePaintForAppearance(e,t,i,n,r,o,a){if(!this.layer)return !1;if(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,a||null),0===this.header[0])return !1;this._ensureRangeMaps();const s=this.featureVertexRangesFromVtIndex.get(e);if(!s)return !1;let l=!1;for(const e of s){const s=this.evaluateAllProperties(t,i,n,r,o,(this.allFormattedSections?this.allFormattedSections[e]:void 0)||void 0,a);l=this._writeFeatureBlock(e,s)||l;}return l}getConstantUniformValues(e,t){const i=!!this.cameraMask;if(this.cachedConstantUniforms&&this.cachedConstantPaint===this.layer.paint&&this.cachedConstantBrightness===t&&(!i||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const n=this.layer.paint,r=i?new Hs(e,{brightness:t,worldview:this.worldview}):null,o={type:1,id:void 0,properties:{},geometry:[]},a=Ud[+this.isText],s=e=>{const i=a[e],s=n.get(i);if(!s)return [0,0,0,1];const l=n.get(`${i}-use-theme`),u=Vd(l&&"string"!=typeof l?l.value:void 0,o,{},[],void 0,t,void 0,this.worldview)?null:this.lut;return (this.cameraMask&1<<e&&r?s.property.evaluate(s.value,r,o,{},void 0,[])||pn.transparent:s.constantOr(pn.transparent)).toNonPremultipliedRenderColor(u).toArray01()},l=(e,t)=>{const i=n.get(a[e]);return i?this.cameraMask&1<<e&&r?i.property.evaluate(i.value,r,o,{},void 0,[])??t:i.constantOr(t):t},u={fill_np_color:s(0),halo_np_color:s(1),opacity:l(2,1),halo_width:l(3,0),halo_blur:l(4,0),emissive_strength:l(5,0),occlusion_opacity:l(6,1),z_offset:l(7,0)};return this.cachedConstantUniforms=u,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,this.cachedConstantPaint=this.layer.paint,u}finalize(){for(const e of this.ubos)e.rightSizeForTransfer();}upload(e){for(const t of this.ubos)t.upload(e);}bind(e,t,i=0){this.ubos[i]&&this.ubos[i].bind(e,t);}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0;}}qa($d,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","cachedConstantPaint","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});const Zd=24;function Wd(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return "uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),js.applyArabicShaping&&(e=js.applyArabicShaping(e)),e}(e.text,t,i);}),e}const qd={horizontal:1,vertical:2,horizontalOnly:3};function Xd(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 Yd(e,t,i,n){const{horizontalAlign:r,verticalAlign:o}=Xd(n),a=i[0]-e.displaySize[0]*r,s=i[1]-e.displaySize[1]*o;return {imagePrimary:e,imageSecondary:t,top:s,bottom:s+e.displaySize[1],left:a,right:a+e.displaySize[0]}}function Jd(e,t,i,n,r,o){const a=e.imagePrimary;let s;if(a.content){const e=a.content,t=a.pixelRatio||1;s=[e[0]/t,e[1]/t,a.displaySize[0]-e[2]/t,a.displaySize[1]-e[3]/t];}const l=t.left*o,u=t.right*o;let c,h,d,f;"width"===i||"both"===i?(f=r[0]+l-n[3],h=r[0]+u+n[1]):(f=r[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const p=t.top*o,_=t.bottom*o;return "height"===i||"both"===i?(c=r[1]+p-n[0],d=r[1]+_+n[2]):(c=r[1]+(p+_-a.displaySize[1])/2,d=c+a.displaySize[1]),{imagePrimary:a,imageSecondary:void 0,top:c,right:h,bottom:d,left:f,collisionPadding:s}}const Kd={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function Qd(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||""===e||" ̄"===e||"︑"===e||"︒"===e}function ef(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const tf=128;function nf(e,t,i,n){const{expression:r}=t;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new Hs(e+1,{worldview:i}),void 0,void 0,void 0,n)};if("source"===r.kind)return {kind:"source"};{const{zoomStops:t,interpolationType:o}=r;let a=0;for(;a<t.length&&t[a]<=e;)a++;a=Math.max(0,a-1);let s=a;for(;s<t.length&&t[s]<e+1;)s++;s=Math.min(t.length-1,s);const l=t[a],u=t[s];return "composite"===r.kind?{kind:"composite",minZoom:l,maxZoom:u,interpolationType:o}:{kind:"camera",minZoom:l,maxZoom:u,minSize:r.evaluate(new Hs(l,{worldview:i}),void 0,void 0,void 0,n),maxSize:r.evaluate(new Hs(u,{worldview:i}),void 0,void 0,void 0,n),interpolationType:o}}}function rf(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return "source"===e.kind?n/tf:"composite"===e.kind?dn(n/tf,r/tf,i):t}function of(e,t,i=1){let n=0,r=0;if("constant"===e.kind)r=e.layoutSize*i;else if("source"!==e.kind){const{interpolationType:o,minZoom:a,maxZoom:s}=e,l=o?tt(Zo.interpolationFactor(o,t,a,s),0,1):0;"camera"===e.kind?r=dn(e.minSize,e.maxSize,l)*i:n=l*i;}return {uSizeT:n,uSize:r}}const af=Number.POSITIVE_INFINITY,sf=Math.sqrt(2),lf=32640;function uf(e,t,i,n,r,o,a){const s=e.hasLayoutProperty(r)?t.getAppearanceValueAndResolveTokens(e,r,i,n,[]):null;return (Array.isArray(o)?Array.isArray(s):typeof s==typeof o)?a?a(s):s:o}function cf(e,t,i,n,r,o,a,s){return {appearanceIconOffset:uf(e,t,i,n,"icon-offset",r),appearanceIconRotate:uf(e,t,i,n,"icon-rotate",o),appearanceIconSize:uf(e,t,i,n,"icon-size",a,e=>e*s)}}function hf(e,t,i,n,r,o,a){const s=uf(e,t,i,n,"text-offset",r,([e,t])=>[e*Zd,t*Zd]);return {appearanceTextOffset:s,appearanceTextRotate:uf(e,t,i,n,"text-rotate",o),appearanceTextSize:uf(e,t,i,n,"text-size",a)}}function df(e,t,i,n,r,o,a,s,l,u){if(!e)return;const c=function(e,t,i,n,r,o,a){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Hs(e.maxZoom,{worldview:o}),i,a).evaluate(r,{},i,a),s=t.possiblyEvaluate(new Hs(e.minZoom,{worldview:o}),i,a).evaluate(r,{},i,a);return Math.max(n,s)}return t.possiblyEvaluate(new Hs(n,{worldview:o}),i,a).evaluate(r,{},i,a)}(t,i,n,r,o,l,u);return e.scaleSelf(c*s*a)}function ff(e,t,i,n,r,o,a,s,l,u){return {iconPrimary:df(e.getPrimary(),t,i,n,r,o,a,s,l,u),iconSecondary:df(e.getSecondary(),t,i,n,r,o,a,s,l,u)}}function pf(e,t){return e*t/24}function _f(e,t,i,n,r,o){let a=null;return "source"===t.kind?(a=[tf*i*n],a[0]>lf&&mt(`${e}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`)):"composite"===t.kind&&(a=[tf*r*n,tf*o*n],(a[0]>lf||a[1]>lf)&&mt(`${e}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`)),a}const mf=Vu([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:gf}=mf,yf=Vu([{name:"a_pos_3",components:3,type:"Int16"}]);var xf=Vu([{name:"a_pos",type:"Int16",components:2}]);class vf{constructor(e,t){this.pos=e,this.dir=t;}intersectsPlane(e,t,i){const n=Se(t,this.dir);if(Math.abs(n)<1e-6)return !1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,!0}}class bf{constructor(e,t){this.pos=e,this.dir=t;}intersectsPlane(e,t,i){const n=W(t,this.dir);if(Math.abs(n)<1e-6)return !1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,i[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],r=e[1],o=e[2],a=t[0],s=t[1],l=t[2];return Math.abs(i-a)<=n*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-s)<=n*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-l)<=n*Math.max(1,Math.abs(o),Math.abs(l))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,o,a]=this.dir,s=this.pos[0]-e[0],l=this.pos[1]-e[1],u=this.pos[2]-e[2],c=r*r+o*o+a*a,h=2*(s*r+l*o+u*a),d=h*h-4*c*(s*s+l*l+u*u-t*t);if(d<0){const e=Math.max(-h/2,0),n=s+r*e,c=l+o*e,d=u+a*e,f=Math.hypot(n,c,d);return i[0]=n*t/f,i[1]=c*t/f,i[2]=d*t/f,!1}{const e=(-h-Math.sqrt(d))/(2*c);if(e<0){const e=Math.hypot(s,l,u);return i[0]=s*t/e,i[1]=l*t/e,i[2]=u*t/e,!1}return i[0]=s+r*e,i[1]=l+o*e,i[2]=u+a*e,!0}}}class wf{constructor(e,t,i,n,r){this.TL=e,this.TR=t,this.BR=i,this.BL=n,this.horizon=r;}static fromInvProjectionMatrix(e,t,i){const n=[-1,1,1],r=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=Y(n,n,e),l=Y(r,r,e),u=Y(o,o,e),c=Y(a,a,e);return new wf(s,l,u,c,t/i)}}function Ef(e,t,i,n){const r=t[0],o=t[1],a=t[2],s=i[0],l=i[1],u=i[2];let c=1/0,h=-1/0;for(let t=0;t<e.length;t++){const i=e[t],n=(i[0]-r)*s+(i[1]-o)*l+(i[2]-a)*u;n<c&&(c=n),n>h&&(h=n);}return n[0]=c,n[1]=h,n}function Af(e,t){let i=!0;for(let n=0;n<e.planes.length;n++){const r=e.planes[n];let o=0;for(let e=0;e<t.length;e++)o+=+(W(r,t[e])+r[3]>=0);if(0===o)return 0;o!==t.length&&(i=!1);}return i?2:1}const If=[0,0];function Tf(e,t){for(const i of e.projections){const n=Ef(t,e.points[0],i.axis,If);if(i.projection[1]<n[0]||i.projection[0]>n[1])return 0}return 1}function Mf(e,t){const i=t[0],n=t[1],r=t[2],o=t[3];for(let t=0;t<e.length;t++){const a=e[t];if(i*a[0]+n*a[1]+r*a[2]+o>=0)return !0}return !1}class Sf{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=zf.fromPoints(this.points),this.projections=[],this.frustumEdges=[te([],this.points[2],this.points[3]),te([],this.points[0],this.points[3]),te([],this.points[4],this.points[0]),te([],this.points[5],this.points[1]),te([],this.points[6],this.points[2]),te([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Ef(this.points,this.points[0],t,[0,0])}),this.projections.push({axis:i,projection:Ef(this.points,this.points[0],i,[0,0])});}}static fromInvProjectionMatrix(e,t,i,n){const r=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(i=>{const o=le([],i,e),a=1/o[3]/t*r;return (s=o)[0]=(l=o)[0]*(u=[a,a,n?1/o[3]:a,a])[0],s[1]=l[1]*u[1],s[2]=l[2]*u[2],s[3]=l[3]*u[3],s;var s,l,u;}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=Z([],q([],te([],o[e[0]],o[e[1]]),te([],o[e[2]],o[e[1]]))),i=-W(t,o[e[1]]);return t.concat(i)}),s=[];for(let e=0;e<o.length;e++)s.push([o[e][0],o[e][1],o[e][2]]);return new Sf(s,a)}intersectsPrecise(e,t,i){for(let i=0;i<t.length;i++)if(!Mf(e,t[i]))return 0;for(let t=0;t<this.planes.length;t++)if(!Mf(e,this.planes[t]))return 0;const n=this.points,r=n[0][0],o=n[0][1],a=n[0][2];for(const t of i)for(const i of this.frustumEdges){const s=t[1]*i[2]-t[2]*i[1],l=t[2]*i[0]-t[0]*i[2],u=t[0]*i[1]-t[1]*i[0];if(0===s&&0===l&&0===u)continue;let c=1/0,h=-1/0;for(let e=0;e<n.length;e++){const t=n[e],i=(t[0]-r)*s+(t[1]-o)*l+(t[2]-a)*u;i<c&&(c=i),i>h&&(h=i);}let d=1/0,f=-1/0;for(let t=0;t<e.length;t++){const i=e[t],n=(i[0]-r)*s+(i[1]-o)*l+(i[2]-a)*u;n<d&&(d=n),n>f&&(f=n);}if(c>f||d>h)return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(W([t[0],t[1],t[2]],e)+i<0)return !1}return !0}}class zf{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const n of e)N(t,t,n),V(i,i,n);return new zf(t,i)}static fromTileIdAndHeight(e,t,i){const n=1<<e.canonical.z,r=e.canonical.x,o=e.canonical.y;return new zf([r/n,o/n,t],[(r+1)/n,(o+1)/n,i])}static applyTransform(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Y(i[e],i[e],t);return zf.fromPoints(i)}static applyTransformFast(e,t){const i=[t[12],t[13],t[14]],n=[...i];for(let r=0;r<3;r++)for(let o=0;o<3;o++){const a=t[4*o+r],s=a*e.min[o],l=a*e.max[o];i[r]+=Math.min(s,l),n[r]+=Math.max(s,l);}return new zf(i,n)}static projectAabbCorners(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Y(i[e],i[e],t);return i}constructor(e,t){this.min=e,this.max=t,this.center=k([],O([],this.min,this.max),.5);}quadrant(e){const t=[e%2==0,e<2],i=P(this.min),n=P(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],n[e]=t[e]?this.center[e]:this.max[e];return n[2]=this.max[2],new zf(i,n)}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]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return [[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Af(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Af(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?Tf(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Tf(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}function Rf(e){return e*au/fu}qa(zf,"Aabb");const Pf=[new zf([uu,uu,uu],[cu,cu,cu]),new zf([uu,uu,uu],[0,0,cu]),new zf([0,uu,uu],[cu,0,cu]),new zf([uu,0,uu],[0,cu,cu]),new zf([0,0,uu],[cu,cu,cu])];function Df(e,t,i,n=!0){const r=k([],e._camera.position,e.worldSize),o=[t,i,1,1];le(o,o,e.pixelMatrixInverse),ae(o,o,1/o[3]);const a=Z([],te([],o,r)),s=e.globeMatrix,l=[s[12],s[13],s[14]],u=te([],l,r),c=D(u),h=Z([],u),d=e.worldSize/(2*Math.PI),f=W(h,a),p=Math.asin(d/c);if(p<Math.acos(f)){if(!n)return null;const e=[],t=[];k(e,a,c/f),Z(t,te(t,e,u)),Z(a,O(a,u,k(a,t,Math.tan(p)*c)));}const _=[];new bf(r,a).closestPointOnSphere(l,d,_);const m=Z([],At(s,0)),g=Z([],At(s,1)),y=Z([],At(s,2)),x=W(m,_),v=W(g,_),b=W(y,_),w=Je(Math.asin(-v/d));let E=Je(Math.atan2(x,b));E=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,E);const A=hr(E),I=tt(dr(w),0,1);return new Iu(A,I)}class Cf{constructor(e,t,i){this.a=te([],e,i),this.b=te([],t,i),this.center=i;const n=Z([],this.a),r=Z([],this.b);this.angle=Math.acos(W(n,r));}}function Ff(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,n){const r=Math.sin(i);return e*(Math.sin((1-n)*i)/r)+t*(Math.sin(n*i)/r)}(e.a[t],e.b[t],e.angle,tt(i,0,1))+e.center[t]}function Of(e){if(e.z<=1)return Pf[e.z+2*e.y+e.x];const t=kf(Vf(e));return zf.fromPoints(t)}function Lf(e,t,i){return k(e,e,1-i),U(e,e,t,i)}function Bf(e,t,i){for(const n of e)Y(n,n,t),k(n,n,i);}function Nf(e,t,i,n){const r=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=Of(i).getCorners();return Bf(e,o,r),zf.fromPoints(e)}const a=Vf(i,n),s=kf(a,au+Rf(e._tileCoverLift));Bf(s,o,r);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(e.center)){for(const e of s)N(c,c,e),V(u,u,e);u[2]=0;const t=e.point,i=[t.x*r,t.y*r,0];return N(c,c,i),V(u,u,i),new zf(c,u)}if(e._tileCoverLift>0){for(const e of s)N(c,c,e),V(u,u,e);return new zf(c,u)}const h=[o[12]*r,o[13]*r,o[14]*r],d=a.getCenter(),f=tt(e.center.lat,-85.051129,vu),p=tt(d.lat,-85.051129,vu),_=hr(e.center.lng),m=dr(f);let g=_-hr(d.lng);const y=m-dr(p);g>.5?g-=1:g<-.5&&(g+=1);let x=0;Math.abs(g)>Math.abs(y)?x=g>=0?1:3:(x=y>=0?0:2,U(h,h,[o[4]*r,o[5]*r,o[6]*r],-Math.sin(Ye(y>=0?a.getSouth():a.getNorth()))*au));const v=s[x],b=s[(x+1)%4],w=new Cf(v,b,h),E=[Ff(w,0)||v[0],Ff(w,1)||v[1],Ff(w,2)||v[2]],A=Xf(e.zoom);if(A>0){const n=function({x:e,y:t,z:i},n,r,o,a){const s=1/(1<<i);let l=e*s,u=l+s,c=t*s,h=c+s,d=0;const f=(l+u)/2-o;return f>.5?d=-1:f<-.5&&(d=1),l=((l+d)*n-(o*=n))*r+o,u=((u+d)*n-o)*r+o,c=(c*n-(a*=n))*r+a,h=(h*n-a)*r+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(i,t,e._pixelsPerMercatorPixel,_,m);for(let e=0;e<s.length;e++)Lf(s[e],n[e],A);const r=O([],n[x],n[(x+1)%4]);k(r,r,.5),Lf(E,r,A);}for(const e of s)N(c,c,e),V(u,u,e);return c[2]=Math.min(v[2],b[2]),N(c,c,E),V(u,u,E),new zf(c,u)}function Vf({x:e,y:t,z:i},n=!1){const r=1/(1<<i),o=new _u(fr(e*r),t===(1<<i)-1&&n?-90:pr((t+1)*r)),a=new _u(fr((e+1)*r),0===t&&n?90:pr(t*r));return new mu(o,a)}function kf(e,t=au){const i=Ye(e.getNorth()),n=Ye(e.getSouth()),r=Math.cos(i),o=Math.cos(n),a=Math.sin(i),s=Math.sin(n),l=e.getWest(),u=e.getEast();return [hu(o,s,l,t),hu(o,s,u,t),hu(r,a,u,t),hu(r,a,l,t)]}function Uf(e,t,i,n){const r=1<<i.z,o=(e/Sr+i.x)/r;return du(pr((t/Sr+i.y)/r),fr(o),n)}function Gf({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const jf=new Float64Array(16);function Hf(e){const t=Gf(e),i=w(jf,[t,t,t]);return m(i,i,$([],e.min))}function $f(e){const t=1/Gf(e);return b(jf,e.min),g(jf,jf,[t,t,t])}function Zf(e){const t=Sr/(2*Math.PI);return e/(2*Math.PI)/t}function Wf(e,t){return Sr/(512*Math.pow(2,e))*Gf(Of(t))}function qf(e,t,i,n,r){const o=Zf(i),a=[e,t,-i/(2*Math.PI)],s=d(new Float64Array(16));return m(s,s,a),g(s,s,[o,o,o]),y(s,s,Ye(-r)),x(s,s,Ye(-n)),s}function Xf(e){return it(5,6,e)}function Yf(e,t){const i=du(t.lat,t.lng),n=function(e){const t=du(e._center.lat,e._center.lng);let i=q([],C(0,1,0),t);const n=E([],-e.angle,t);i=Y(i,i,n),E(n,-e._pitch,i);const r=Z([],t);return k(r,r,Rf(e.cameraToCenterDistance/e.pixelsPerMeter)),Y(r,r,n),O([],t,r)}(e);return a=(r=L([],n,i))[0],s=r[1],l=r[2],u=(o=i)[0],c=o[1],h=o[2],f=(d=Math.sqrt((a*a+s*s+l*l)*(u*u+c*c+h*h)))&&W(r,o)/d,Math.acos(Math.min(Math.max(f,-1),1));var r,o,a,s,l,u,c,h,d,f;}function Jf(e,t){return Yf(e,t)>Math.PI/2*1.01}const Kf=Ye(85),Qf=Math.cos(Kf),ep=Math.sin(Kf);function tp(e,t){const i=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,r=Math.min(n,e.isOrthographic?-10*t:0),o=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),a=Math.sin(i)*o/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01));let s=Math.sin(e._pitch)*a+o;const l=o*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10),s*=1+t;}return Math.min(1.01*s,l)}class ip{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=op(0,e,e,t,i);}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return 0===e.z||e.z<this.z&&e.x===this.x>>t&&e.y===this.y>>t}url(e,t){const i=function(e,t,i){const n=2**i,r=2*Math.PI*6378137,o=r*(e/n-.5),a=r*(.5-(t+1)/n);return `${o},${a},${o+r/n},${a+r/n}`}(this.x,this.y,this.z),n=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<<o-1,r+=(t&n?1:0)+(i&n?2:0);return r}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(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"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",n).replace("{bbox-epsg-3857}",i)}toString(){return `${this.z}/${this.x}/${this.y}`}}class np{constructor(e,t){this.wrap=e,this.canonical=t,this.key=op(e,t.z,t.z,t.x,t.y);}}class rp{constructor(e,t,i,n,r){this.overscaledZ=e,this.wrap=t,this.canonical=new ip(i,+n,+r),this.key=0===t&&e===i?this.canonical.key:op(t,e,i,n,r);}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new rp(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new rp(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return op(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return op(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new rp(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,n=2*this.canonical.y;return [new rp(t,this.wrap,t,i,n),new rp(t,this.wrap,t,i+1,n),new rp(t,this.wrap,t,i,n+1),new rp(t,this.wrap,t,i+1,n+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 rp(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new rp(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 np(this.wrap,this.canonical)}toString(){return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function op(e,t,i,n,r){const o=1<<Math.min(i,22);let a=o*(r%o)+n%o;return e&&i<22&&(a+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*a+i)+(t-i)}const ap=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new rp(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new rp(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new rp(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new rp(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];function sp(e,t){if(!t.isReprojectedInTileSpace)return {scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),n=e.x*i,r=(e.x+1)*i,o=e.y*i,a=(e.y+1)*i,s=fr(n),l=fr(r),u=pr(o),c=pr(a),h=t.project(s,u),d=t.project(l,u),f=t.project(l,c),p=t.project(s,c);let _=Math.min(h.x,d.x,f.x,p.x),m=Math.min(h.y,d.y,f.y,p.y),g=Math.max(h.x,d.x,f.x,p.x),y=Math.max(h.y,d.y,f.y,p.y);const x=i/16;function v(e,i,n,r,o,a){const s=(n+o)/2,l=(r+a)/2,u=t.project(fr(s),pr(l)),c=Math.max(0,_-u.x,m-u.y,u.x-g,u.y-y);_=Math.min(_,u.x),g=Math.max(g,u.x),m=Math.min(m,u.y),y=Math.max(y,u.y),c>x&&(v(e,u,n,r,s,l),v(u,i,s,l,o,a));}v(h,d,n,o,r,o),v(d,f,r,o,r,a),v(f,p,r,a,n,a),v(p,h,n,a,n,o),_-=x,m-=x,g+=x,y+=x;const b=1/Math.max(g-_,y-m);return {scale:b,x:_*b,y:m*b,x2:g*b,y2:y*b,projection:t}}function lp(e,t,i,n,r,o,a,s,l){if("globe"===l.name)return Nf(e,t,new ip(i,n,r),!1);const u=sp({z:i,x:n,y:r},l);return new zf([(o+u.x/u.scale)*t,t*(u.y/u.scale),a],[(o+u.x2/u.scale)*t,t*(u.y2/u.scale),s])}qa(ip,"CanonicalTileID"),qa(rp,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const up=d(new Float32Array(16));class cp{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new _u(0,0)}projectTilePoint(e,t,i){return {x:e,y:t,z:0}}locationPoint(e,t,i,n=!0){return e._coordinatePoint(e.locationCoordinate(t,i),n)}pixelsPerMeter(e,t){return yu(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return tp(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const r=e.horizonLineFromTop(!1),o=new Pe(t,Math.max(r,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,n))}pointCoordinate3D(e,t,i){const n=new Pe(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return up}createTileMatrix(e,t,i){let n,r,o;const a=i.canonical,s=d(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=sp(a,this);n=1,r=l.x+i.wrap*l.scale,o=l.y,g(s,s,[n/l.scale,n/l.scale,e.pixelsPerMeter/t]);}else n=t/e.zoomScale(a.z),r=(a.x+Math.pow(2,a.z)*i.wrap)*n,o=a.y*n;return m(s,s,[r,o,0]),g(s,s,[n/Sr,n/Sr,1]),s}upVector(e,t,i){return [0,0,1]}upVectorScale(e,t,i){return {metersToTile:1}}}class hp extends cp{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],n=Math.sin(Ye(t));this.n=(n+Math.sin(Ye(i)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n;}project(e,t){const{n:i,c:n,r0:r}=this,o=Ye(e-this.center[0]),a=Ye(t),s=Math.sqrt(n-2*i*Math.sin(a))/i;return {x:s*Math.sin(o*i),y:s*Math.cos(o*i)-r,z:0}}unproject(e,t){const{n:i,c:n,r0:r}=this,o=r+t;let a=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(a-=Math.PI*Math.sign(e)*Math.sign(o));const s=Ye(this.center[0])*i;a=nt(a,-Math.PI-s,Math.PI-s);const l=tt(Je(a/i)+this.center[0],-180,180),u=Math.asin(tt((n-(e*e+o*o)*i*i)/(2*i),-1,1)),c=tt(Je(u),-85.051129,vu);return new _u(l,c)}}const dp=1.340264,fp=-.081106,pp=893e-6,_p=.003796,mp=Math.sqrt(3)/2;class gp extends cp{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(mp*Math.sin(t)),n=i*i,r=n*n*n;return {x:.5*(e*Math.cos(i)/(mp*(dp+3*fp*n+r*(7*pp+9*_p*n)))/Math.PI+.5),y:1-.5*(i*(dp+fp*n+r*(pp+_p*n))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=i*i,r=n*n*n;for(let e,o,a,s=0;s<12&&(o=i*(dp+fp*n+r*(pp+_p*n))-t,a=dp+3*fp*n+r*(7*pp+9*_p*n),e=o/a,i=tt(i-e,-Math.PI/3,Math.PI/3),n=i*i,r=n*n*n,!(Math.abs(e)<1e-12));++s);const o=mp*e*(dp+3*fp*n+r*(7*pp+9*_p*n))/Math.cos(i),a=Math.asin(Math.sin(i)/mp),s=tt(180*o/Math.PI,-180,180),l=tt(180*a/Math.PI,-85.051129,vu);return new _u(s,l)}}class yp extends cp{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){return {x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),n=tt(360*(.5-t),-85.051129,vu);return new _u(i,n)}}const xp=Math.PI/2;function vp(e){return Math.tan((xp+e)/2)}class bp extends cp{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30];let n=Ye(t),r=Ye(i);this.southernCenter=n+r<0,this.southernCenter&&(n=-n,r=-r);const o=Math.cos(n),a=vp(n);this.n=n===r?Math.sin(n):Math.log(o/Math.cos(r))/Math.log(vp(r)/a),this.f=o*Math.pow(vp(n),this.n)/this.n;}project(e,t){t=Ye(t),this.southernCenter&&(t=-t),e=Ye(e-this.center[0]);const i=1e-6,{n,f:r}=this;r>0?t<-xp+i&&(t=-xp+i):t>xp-i&&(t=xp-i);const o=r/Math.pow(vp(t),n);let a=o*Math.sin(n*e),s=r-o*Math.cos(n*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:n}=this,r=n-t,o=Math.sign(r),a=Math.sign(i)*Math.sqrt(e*e+r*r);let s=Math.atan2(e,Math.abs(r))*o;r*i<0&&(s-=Math.PI*Math.sign(e)*o);const l=tt(Je(s/i)+this.center[0],-180,180),u=tt(Je(2*Math.atan(Math.pow(n/a,1/i))-xp),-85.051129,vu);return new _u(l,this.southernCenter?-u:u)}}class wp extends cp{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:hr(e),y:dr(t),z:0}}unproject(e,t){const i=fr(e),n=pr(t);return new _u(i,n)}}const Ep=Ye(vu);class Ap extends cp{project(e,t){const i=(t=Ye(t))*t,n=i*i;return {x:.5*((e=Ye(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const e=o*o;r=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=tt(i-r,-Ep,Ep);}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const a=tt(Je(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=Je(i);return new _u(a,s)}}const Ip=Ye(vu);class Tp extends cp{project(e,t){t=Ye(t),e=Ye(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,a=.5*(e*n+2*i*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,r=25;const o=1e-6;let a=0,s=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,u=o*o,c=r*r,h=Math.cos(i/2),d=Math.sin(i/2),f=2*h*d,p=d*d,_=1-c*h*h,m=_?1/_:0,g=_?Math.acos(r*h)*Math.sqrt(1/_):0,y=.5*(2*g*r*d+2*i/Math.PI)-e,x=.5*(g*o+n)-t,v=.5*m*(c*p+g*r*h*u)+1/Math.PI,b=m*(f*l/4-g*o*d),w=.125*m*(l*d-g*o*c*f),E=.5*m*(u*h+g*p*r)+.5,A=b*w-E*v;a=(x*b-y*E)/A,s=(y*w-x*v)/A,i=tt(i-a,-Math.PI,Math.PI),n=tt(n-s,-Ip,Ip);}while((Math.abs(a)>o||Math.abs(s)>o)&&--r>0);return new _u(Je(i),Je(n))}}class Mp extends cp{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ye(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:i,cosPhi:n}=this;return {x:Ye(e)*n*i+.5,y:-Math.sin(Ye(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=tt(Je((e-.5)/i)/n,-180,180),a=Math.asin(tt(r*n,-1,1)),s=tt(Je(a),-85.051129,vu);return new _u(o,s)}}class Sp extends wp{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,i){const n=Uf(e,t,i);return Y(n,n,Hf(Of(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,i){const n=du(t.lat,t.lng),r=Z([],n),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;U(n,n,r,yu(1,0)*Sr*o);const a=d(new Float64Array(16));return _(a,e.pixelMatrix,e.globeMatrix),Y(n,n,a),new Pe(n[0],n[1])}pixelsPerMeter(e,t){return yu(1,0)*t}pixelSpaceConversion(e,t,i){const n=yu(1,e)*t,r=dn(yu(1,45)*t,n,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const n=$f(Of(i.canonical));return _(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=Hf(Of(t));return x(n,n,Ye(i.lng)),y(n,n,Ye(i.lat)),g(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return Df(e,t,i,!0)||new Iu(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return [n.x,n.y,n.z]}isPointAboveHorizon(e,t){return !Df(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,o=e._camera.forward(),a=O([],k([],o,-i),[0,0,n]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=k([],r.up(),c),d=k([],r.right(),c*u),f=Z([],O([],O([],o,h),d)),p=[];let _;if(new bf(a,f).closestPointOnSphere(l,s,p)){const t=O([],p,l),i=te([],t,a);_=Math.cos(e.fovAboveCenter)*D(i);}else {const e=te([],a,l),t=te([],l,a);Z(t,t);const i=D(e)-s;_=Math.sqrt(i*(i+2*s));const n=Math.acos(_/(s+i))-Math.acos(W(o,t));_*=Math.cos(n);}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Xf(e.zoom);if(i>0){const n=tp(e,yu(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return dn(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Uf(t,i,e,1)}upVectorScale(e){return {metersToTile:Rf(Gf(Of(e)))}}}function zp(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case "mercator":return new wp(e);case "equirectangular":return new yp(e);case "naturalEarth":return new Ap(e);case "equalEarth":return new gp(e);case "winkelTripel":return new Tp(e);case "albers":return i?new Mp(e):new hp(e);case "lambertConformalConic":return i?new Mp(e):new bp(e);case "globe":return new Sp(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Rp=Number.MAX_SAFE_INTEGER,Pp=Rp-1;function Dp(e,t,i,n){return e.order<t||e.order===Rp||!(e.clipMask&i)||function(e,t){if(0===t.length)return !1;let i=e;for(;""!==i;){if(t.includes(i))return !1;i=bl(i);}return !0}(n,e.clipScope)}function Cp(e,t){return e.x-t.x||e.y-t.y}function Fp(e,t){return 0===Cp(e.min,t.min)&&0===Cp(e.max,t.max)}function Op(e,t){return !(e.min.x>t.max.x||e.max.x<t.min.x||e.min.y>t.max.y||e.max.y<t.min.y)}function Lp(e,t){if(e.length!==t.length)return !1;for(let i=0;i<e.length;i++)if(e[i].sourceId!==t[i].sourceId||!Fp(e[i],t[i])||e[i].order!==t[i].order||e[i].clipMask!==t[i].clipMask||!De(e[i].clipScope,t[i].clipScope))return !1;return !0}function Bp(e,t,i){const n=1/Sr,r=1/(1<<i.canonical.z),o=(t.x*n+i.canonical.x)*r+i.wrap,a=(t.y*n+i.canonical.y)*r;return {min:new Pe((e.x*n+i.canonical.x)*r+i.wrap,(e.y*n+i.canonical.y)*r),max:new Pe(o,a)}}function Np(e,t,i){const n=1<<i.canonical.z,r=((t.x-i.wrap)*n-i.canonical.x)*Sr,o=(t.y*n-i.canonical.y)*Sr;return {min:new Pe(((e.x-i.wrap)*n-i.canonical.x)*Sr,(e.y*n-i.canonical.y)*Sr),max:new Pe(r,o)}}function Vp(e,t,i,n,r,o,a){const s=e.indices,l=e.vertices,u=[];for(let c=n;c<n+r;c+=3){const n=t[i[c+0]+o],r=t[i[c+1]+o],h=t[i[c+2]+o],d=Math.min(n.x,r.x,h.x),f=Math.max(n.x,r.x,h.x),p=Math.min(n.y,r.y,h.y),_=Math.max(n.y,r.y,h.y);u.length=0,e.grid.query(new Pe(d,p),new Pe(f,_),u);for(let e=0;e<u.length;e++){const t=u[e];if(Jh(l[s[3*t+0]],l[s[3*t+1]],l[s[3*t+2]],n,r,h,a))return !0}}return !1}function kp(e,t,i,n){if(!e||!i)return !1;let r=e.vertices;if(!t.canonical.equals(n.canonical)||t.wrap!==n.wrap){if(i.vertices.length<e.vertices.length)return kp(i,n,e,t);const o=t.canonical,a=n.canonical,s=Math.pow(2,a.z-o.z);r=e.vertices.map(e=>new Pe((e.x+o.x*Sr)*s-a.x*Sr,(e.y+o.y*Sr)*s-a.y*Sr));}return Vp(i,r,e.indices,0,e.indices.length,0,0)}function Up(e,t,i,n){const r=Math.pow(2,n.z-i.z);return new Pe((e+i.x*Sr)*r-n.x*Sr,(t+i.y*Sr)*r-n.y*Sr)}function Gp(e,t){const i=[];t.grid.queryPoint(e,i);const n=t.indices,r=t.vertices;for(let t=0;t<i.length;t++){const o=i[t];if(Wh([r[n[3*o+0]],r[n[3*o+1]],r[n[3*o+2]]],e))return !0}return !1}const jp=4294967296,Hp=1/jp,$p="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Zp{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length;}readFields(e,t,i=this.length){let n;for(;n=this.nextField(i);)e(n,t,this);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)*jp;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*jp;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,i=t[this.pos++];if(i<128)return i;let n,r=127&i;return n=t[this.pos++],r|=(127&n)<<7,n<128?r:(n=t[this.pos++],r|=(127&n)<<14,n<128?r:(n=t[this.pos++],r|=(127&n)<<21,n<128?r:(n=t[this.pos],r|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Wp(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Wp(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Wp(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Wp(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Wp(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Wp(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(r,e,this))))}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&&$p?$p.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r<i;){const t=e[r];let o,a,s,l=null,u=t>239?4:t>223?3:t>191?2:1;if(r+u>i)break;1===u?t<128&&(l=t):2===u?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===u?(o=e[r+1],a=e[r+2],128==(192&o)&&128==(192&a)&&(l=(15&t)<<12|(63&o)<<6|63&a,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(o=e[r+1],a=e[r+2],s=e[r+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(l=(15&t)<<18|(63&o)<<12|(63&a)<<6|63&s,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=u;}return n}(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}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;const t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}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;}}}function Wp(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function qp(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n),i.buf.copyWithin(e+n,e,i.pos);}function Xp(e,t){const i=e.length;let n=t.buf,r=t.pos,o=t.length;for(let a=0;a<i;a++){let i=e[a];if(i<0||r+10>o)t.pos=r,t.writeVarint(i),n=t.buf,r=t.pos,o=t.length;else {for(;i>127;)n[r++]=i%128|128,i=Math.floor(i/128);n[r++]=i;}}t.pos=r;}function Yp(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i]);}function Jp(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i]);}function Kp(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i]);}function Qp(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i]);}function e_(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i]);}function t_(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i]);}function i_(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i]);}function n_(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i]);}function r_(e,t,i){let n;for(;n=e.nextField(t);)3===n?i.glyphs.push(o_(e,e.readVarint()+e.pos)):4===n?i.ascender=e.readSVarint():5===n&&(i.descender=e.readSVarint());}function o_(e,t){let i,n,r=0,o=0,a=0,s=0,l=0,u=0;for(;n=e.nextField(t);)1===n?r=e.readVarint():2===n?i=e.readBytes():3===n?o=e.readVarint():4===n?a=e.readVarint():5===n?s=e.readSVarint():6===n?l=e.readSVarint():7===n&&(u=e.readVarint());return {id:r,bitmap:new ld({width:o+6,height:a+6},i),metrics:{width:o,height:a,left:s,top:l,advance:u}}}function a_(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e<n.length&&(n[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):(n.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:r,h:o,fill:t/(r*o)||0}}function s_(e,t){return e.id<t.id?-1:e.id>t.id?1:e.version<t.version?-1:e.version>t.version?1:e.sx<t.sx?-1:e.sx>t.sx?1:e.sy<t.sy?-1:e.sy>t.sy?1:0}function l_(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return t}function u_(e,t){return (e<<5)-e+t}function c_(e,t,i,n){for(const[r]of e.entries()){const e=n&&n.get(r)||Un.parse(r),o=e.id.toString(),a=t.get(o)||0;i.push({id:r,version:a,sx:e.sx,sy:e.sy});}}class h_{constructor(e,t,i,n,r="",o){this.scope=r,this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=t.size>0,c_(e,i,this.iconDescriptors,o),c_(t,i,this.patternDescriptors,o),this.iconDescriptors.sort(s_),this.patternDescriptors.sort(s_);let a=0;a=u_(a,l_(r)),a=u_(a,1);const s=n?n.data:"";s&&(a=u_(a,l_(s))),a=u_(a,1);for(const e of this.iconDescriptors)a=u_(a,l_(e.id)),a=u_(a,e.version),a=u_(a,e.sx),a=u_(a,e.sy);a=u_(a,1);for(const e of this.patternDescriptors)a=u_(a,l_(e.id)),a=u_(a,e.version),a=u_(a,e.sx),a=u_(a,e.sy);this.hash=a;}subsetOf(e){return this.scope===e.scope&&this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,s_)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,s_)}isSubsetArray(e,t,i){let n=0,r=0;if(e.length>t.length)return !1;for(;n<e.length&&r<t.length;){const o=i(e[n],t[r]);if(0===o)n++,r++;else {if(o<0)return !1;r++;}}return n===e.length}}function d_(e){switch(e){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function f_(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}qa(h_,"AtlasContentDescriptor");class p_{constructor(e,t,i,n){this.context=e,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply});}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:r}=this,{gl:o}=r,{x:a,y:s}=t&&t.position?t.position:{x:0,y:0},l=a+i,u=s+n;this.size&&(this.size[0]!==l||this.size[1]!==u)&&(!t||void 0===t.recreateWhenResize||t.recreateWhenResize)&&(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const c=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,u),this.size=[l,u];}this.size&&(c?o.texSubImage2D(o.TEXTURE_2D,0,a,s,d_(this.format),f_(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,a,s,i,n,d_(this.format),f_(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D);}bind(e,t,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,i,n,r){const{context:o}=this,{gl:a}=o;a.bindTexture(a.TEXTURE_2D,this.texture),t!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n),r!==this.compareMode&&(r?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_FUNC,r)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.NONE),this.compareMode=r);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class __{constructor(e,t,i,n){this.context=e,this.format=n,this.size=i,this.texture=e.gl.createTexture();const[r,o,a]=this.size,{gl:s}=e;s.bindTexture(s.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&s.texImage3D(s.TEXTURE_3D,0,this.format,r,o,a,0,d_(this.format),f_(this.format),t.data);}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class m_{static getImagePositionScale(e,t,i){if(t&&e){const{sx:t,sy:i}=e;return {x:t,y:i}}return {x:i,y:i}}constructor(e,t,i,n){this.paddedRect=e;const{pixelRatio:r,version:o,stretchX:a,stretchY:s,content:l,sdf:u,usvg:c}=t;this.pixelRatio=r,this.stretchX=a,this.stretchY=s,this.content=l,this.version=o,this.padding=i,this.sdf=u,this.usvg=c,this.scale=m_.getImagePositionScale(n,c,r);}get tl(){return [this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return [this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return [(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function g_(e,t,i){const n=Un.parse(e),r=function(e,t,i=[1,1]){return {x:0,y:0,w:(e.data?e.data.width:e.width*i[0])+2*t,h:(e.data?e.data.height:e.height*i[1])+2*t}}(t,i,[n.sx,n.sy]);return {bin:r,imagePosition:new m_(r,t,i,n),imageVariant:n}}function y_(e,t){const i=[];for(const[n,r]of e.entries()){const e=Un.parse(n);e&&(i.push({key:n,value:r,variant:e}),t&&t.set(n,e));}i.sort((e,t)=>{const i=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==i?i:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:e.key.localeCompare(t.key)});const n=new Map;for(const e of i)n.set(e.key,e.value);return n}class x_{constructor(e){this.sourceAtlasHash=e;}}class v_{constructor(e,t,i,n,r=""){const o=new Map,a=new Map;this.haveRenderCallbacks=[];const s=[],l=void 0!==n,u=l?new Map:void 0,c=l?y_(e,u):e,h=l?y_(t,u):t;this.addImages(c,o,1,s),this.addImages(h,a,2,s);const{w:d,h:f}=a_(s),p=new ud({width:d||1,height:f||1});for(const[e,t]of c.entries()){const i=o.get(e).paddedRect;ud.copy(t.data,p,{x:0,y:0},{x:i.x+1,y:i.y+1},t.data,null,t.sdf);}for(const[e,t]of h.entries()){const n=a.get(e),r=n.paddedRect;let o=n.padding;const s=r.x+o,l=r.y+o,u=t.data.width,c=t.data.height;o=o>1?o-1:o,ud.copy(t.data,p,{x:0,y:0},{x:s,y:l},t.data,i),ud.copy(t.data,p,{x:0,y:c-o},{x:s,y:l-o},{width:u,height:o},i),ud.copy(t.data,p,{x:0,y:0},{x:s,y:l+c},{width:u,height:o},i),ud.copy(t.data,p,{x:u-o,y:0},{x:s-o,y:l},{width:o,height:c},i),ud.copy(t.data,p,{x:0,y:0},{x:s+u,y:l},{width:o,height:c},i),ud.copy(t.data,p,{x:u-o,y:c-o},{x:s-o,y:l-o},{width:o,height:o},i),ud.copy(t.data,p,{x:0,y:c-o},{x:s+u,y:l-o},{width:o,height:o},i),ud.copy(t.data,p,{x:0,y:0},{x:s+u,y:l+c},{width:o,height:o},i),ud.copy(t.data,p,{x:u-o,y:0},{x:s-o,y:l+c},{width:o,height:o},i);}this.lut=i,this.image=p,this.iconPositions=o,this.patternPositions=a,l&&(this.contentDescriptor=new h_(c,h,n,i,r,u));}addImages(e,t,i,n){for(const[r,o]of e.entries()){const{bin:e,imagePosition:a,imageVariant:s}=g_(r,o,i);t.set(r,a),n.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(s.id);}}patchUpdatedImages(e,t,i,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r of e.getUpdatedImages(i)){for(const n of this.iconPositions.keys()){const o=Un.parse(n);if(ln.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.iconPositions.get(n),o,t,null);}}for(const o of this.patternPositions.keys()){const a=Un.parse(o);if(ln.isEqual(a.id,r)){const a=e.getImage(r,i);this.patchUpdatedImage(this.patternPositions.get(o),a,t,n||this.lut);}}}}patchUpdatedImage(e,t,i,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,o]=e.tl,a=e.sdf;if(this.lut||a){const e={width:t.data.width,height:t.data.height},s=new ud(e);ud.copy(t.data,s,{x:0,y:0},{x:0,y:0},e,n,a),i.update(s,{position:{x:r,y:o},recreateWhenResize:!1});}else i.update(t.data,{position:{x:r,y:o},recreateWhenResize:!1});}}qa(m_,"ImagePosition"),qa(v_,"ImageAtlas",{omit:["lut"]}),qa(x_,"ImageAtlasReference");class b_{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client";}loadGlyphRange(e,t,i,n,r){if("server"===this.fontstackCompositing)return void b_.loadGlyphRange(e,t,i,n,r);const o=e.split(",").map(e=>e.trim()).filter(e=>e.length>0);0!==o.length?1!==o.length?this._loadMultipleFonts(o,t,i,n,r):this._loadFont(o[0],t,i,n,r):r(new Error("Empty fontstack"));}_loadMultipleFonts(e,t,i,n,r){const o=e.map(()=>null),a={completed:0,firstError:null,callbackCalled:!1},s=(t,i,n)=>{if(!a.callbackCalled&&(i&&!a.firstError&&(a.firstError=i),n&&(o[t]=n),a.completed++,a.completed===e.length)){a.callbackCalled=!0;const e=o.filter(e=>null!==e);if(0===e.length)return void r(a.firstError||new Error("All fonts failed to load"));const t=this._composeGlyphs(e);r(null,t);}};for(let r=0;r<e.length;r++)this._loadFont(e[r],t,i,n,(e,t)=>{s(r,e,t);});}_loadFont(e,t,i,n,r){const o=`${e}:${t}`;if(this.cachedRanges.has(o)){const e=this.cachedRanges.get(o);return void Vt.frame(()=>r(null,e))}const a=this.pendingRequests.get(o);a?a.push(r):(this.pendingRequests.set(o,[r]),b_.loadGlyphRange(e,t,i,n,(e,t)=>{e||this.cachedRanges.set(o,t||null);const i=this.pendingRequests.get(o);if(this.pendingRequests.delete(o),i)for(const n of i)n(e,t);}));}_composeGlyphs(e){const t={};let i,n;for(const r of e)if(void 0===i&&void 0!==r.ascender&&(i=r.ascender),void 0===n&&void 0!==r.descender&&(n=r.descender),r.glyphs)for(const e in r.glyphs)void 0===t[e]&&(t[e]=r.glyphs[e]);return {glyphs:t,ascender:i,descender:n}}}b_.loadGlyphRange=async function(e,t,i,n,r){const o=256*t,a=o+255;let s;try{const t=await n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${a}`),ai.Glyphs),{data:r}=await _i(t),l={},u=function(e){return function(e){const t={glyphs:[]};let i;for(;i=e.nextField();)1===i&&r_(e,e.readVarint()+e.pos,t);return t}(new Zp(e))}(r);for(const e of u.glyphs)l[e.id]=e;s={glyphs:l,ascender:u.ascender,descender:u.descender};}catch(e){return r(e)}r(null,s);};const w_=1e20,E_=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);E_[e]=t*Math.abs(t);}function A_(e,t,i,n,r,o,a,s,l){for(let u=t;u<t+n;u++)I_(e,i*o+u,o,r,a,s,l);for(let u=i;u<i+r;u++)I_(e,u*o+t,1,n,a,s,l);}function I_(e,t,i,n,r,o,a){o[0]=0,a[0]=-w_,a[1]=w_,r[0]=e[t];for(let s=1,l=0,u=0;s<n;s++){r[s]=e[t+s*i];const n=s*s;do{const e=o[l];u=(r[s]-r[e]+n-e*e)/(s-e)/2;}while(u<=a[l]&&--l>-1);l++,o[l]=s,a[l]=u,a[l+1]=w_;}for(let s=0,l=0;s<n;s++){for(;a[l+1]<s;)l++;const n=o[l],u=s-n;e[t+s*i]=r[n]+u*u;}}E_[255]=-w_;const T_=/bold/i,M_=/medium/i,S_=/light/i,z_={none:0,ideographs:1,all:2};class R_{constructor(e,t,i,n){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new b_({fontstackCompositing:n});}setURL(e){this.url=e;}prefetchRange(e,t){const i=this.url||Ut.GLYPHS_URL;if(!i)return;let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{}}),n.ranges[t]||n.requests[t]||(n.requests[t]=[],this.glyphLoader.loadGlyphRange(e,t,i,this.requestManager,(e,i)=>{if(i){n.ascender=i.ascender,n.descender=i.descender;for(const e in i.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=i.glyphs[+e]);n.ranges[t]=!0;}for(const r of n.requests[t]||[])r(e,i);delete n.requests[t];}));}getGlyphs(e,t){const i=[],n=this.url||Ut.GLYPHS_URL;for(const t in e)for(const n of e[t])i.push({stack:t,id:n});rt(i,({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const a=Math.floor(t/256);if(256*a>65535)return mt("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(r.ranges[a])return void i(null,{stack:e,id:t,glyph:o});let s=r.requests[a];s||(s=r.requests[a]=[],this.glyphLoader.loadGlyphRange(e,a,n,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[a]=!0;}for(const i of s)i(e,t);delete r.requests[a];})),s.push((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null});});},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e);}});}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==z_.none&&(this.localGlyphMode===z_.all?!!this.localFontFamily:!!this.localFontFamily&&(ms(e)||xs(e)||ss(e)||ls(e)||as(e)||_s(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t;}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";T_.test(t)?i="900":M_.test(t)?i="500":S_.test(t)&&(i="200"),r=e.tinySDF=new R_.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i;}const o=r.fontWeight;if(this.localGlyphs[o][i])return this.localGlyphs[o][i];const a=String.fromCodePoint(i),{data:s,width:l,height:u,glyphWidth:c,glyphHeight:h,glyphLeft:d,glyphTop:f,glyphAdvance:p}=r.draw(a);return this.localGlyphs[o][i]={id:i,bitmap:new ld({width:l,height:u},s),metrics:{width:c/2,height:h/2,left:d/2,top:f/2-27,advance:p/2,localGlyph:!0}}}}function P_(e,t){return e+t[1]-t[0]}function D_(e,t,i,n,r=1){const o=[],a=e.imagePrimary,s=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=(e.right-e.left)*r,h=(e.bottom-e.top)*r,d=a.stretchX||[[0,l]],f=a.stretchY||[[0,u]],p=d.reduce(P_,0),_=f.reduce(P_,0),m=l-p,g=u-_;let y=0,x=p,v=0,b=_,w=0,E=m,A=0,I=g;if(a.content&&n){const e=a.content;y=C_(d,0,e[0]),v=C_(f,0,e[1]),x=C_(d,e[0],e[2]),b=C_(f,e[1],e[3]),w=e[0]-y,A=e[1]-v,E=e[2]-e[0]-x,I=e[3]-e[1]-b;}const T=(n,o,l,u)=>{const d=L_(n.stretch-y,x,c,e.left*r),f=B_(n.fixed-w,E,n.stretch,p),m=L_(o.stretch-v,b,h,e.top*r),g=B_(o.fixed-A,I,o.stretch,_),T=L_(l.stretch-y,x,c,e.left*r),M=B_(l.fixed-w,E,l.stretch,p),S=L_(u.stretch-v,b,h,e.top*r),z=B_(u.fixed-A,I,u.stretch,_),R=new Pe(d,m),P=new Pe(T,m),D=new Pe(T,S),C=new Pe(d,S),F=new Pe(f/s,g/s),O=new Pe(M/s,z/s),L=t*Math.PI/180;if(L){const e=Math.sin(L),t=Math.cos(L),i=[t,-e,e,t];R._matMult(i),P._matMult(i),C._matMult(i),D._matMult(i);}const B=n.stretch+n.fixed,N=l.stretch+l.fixed,V=o.stretch+o.fixed,k=u.stretch+u.fixed,U=e.imageSecondary;return {tl:R,tr:P,bl:C,br:D,texPrimary:{x:a.paddedRect.x+1+B,y:a.paddedRect.y+1+V,w:N-B,h:k-V},texSecondary:U?{x:U.paddedRect.x+1+B,y:U.paddedRect.y+1+V,w:N-B,h:k-V}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:O,minFontScaleX:E/s/c,minFontScaleY:I/s/h,isSDF:i}};if(a.stretchX||a.stretchY){const e=F_(d,m,p),t=F_(f,g,_);for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)o.push(T(n,t[e],r,t[e+1]));}}else o.push(T({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return o}function C_(e,t,i){let n=0;for(const r of e)n+=Math.max(t,Math.min(i,r[1]))-Math.max(t,Math.min(i,r[0]));return n}function F_(e,t,i){const n=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=n.at(-1);n.push({fixed:t-e.stretch,stretch:e.stretch}),n.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)});}return n.push({fixed:t+1,stretch:i}),n}function O_(e){return 2*e.length+1}function L_(e,t,i,n){return e/t*i+n}function B_(e,t,i,n){return e-t*i/n}function N_(e,t,i,n){const r=t+e.positionedLines[n].lineOffset;return 0===n?i+r/2:i+(r+(t+e.positionedLines[n-1].lineOffset))/2}function V_(e,t,i,n,r,o,a,s,l,u=1){const c=[];if(0===t.positionedLines.length)return c;const h=(void 0!==l?l:n.layout.get("text-rotate").evaluate(o,{}))*Math.PI/180,d=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let f=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)f-=e.lineOffset;const p=t.positionedLines.length,_=f/p;let m=t.top-i[1];for(let e=0;e<p;++e){const n=t.positionedLines[e];m=N_(t,_,m,e);for(const e of n.positionedGlyphs){if(!e.rect)continue;const n=e.rect||{};let o=4,l=!0,f=1,p=0;if(e.image){const t=a.get(e.image.toString());if(!t)continue;if(t.sdf){mt("SDF images are not supported in formatted text and will be ignored.");continue}l=!1,f=t.pixelRatio,o=1/f,t.usvg||(f/=u);}const _=(r||s)&&e.vertical,g=e.metrics.advance*e.scale/2,y=e.metrics,x=e.rect;if(null===x)continue;s&&t.verticalizable&&(p=e.image?g-e.metrics.width*e.scale/2:0);const v=r?[e.x+g,e.y]:[0,0];let b=[0,0],w=[0,0],E=!1;r||(_?(w=[e.x+g+d[0],e.y+d[1]-p],E=!0):b=[e.x+g+i[0],e.y+i[1]-p]);const A=x.w*e.scale/(f*(e.localGlyph?2:1)),I=x.h*e.scale/(f*(e.localGlyph?2:1));let T,M,S,z;if(_){const t=e.y-m,i=new Pe(-g,g-t),n=-Math.PI/2,r=new Pe(...w);T=new Pe(-g+b[0],b[1]),T._rotateAround(n,i)._add(r),T.x+=-t+g,T.y-=(y.left-o)*e.scale;const a=e.image?y.advance*e.scale:Zd*e.scale,s=String.fromCodePoint(e.glyph);Qd(s)?T.x+=(1-o)*e.scale:ef(s)?T.x+=a-y.height*e.scale+(-o-1)*e.scale:T.x+=e.image||y.width+2*o===x.w&&y.height+2*o===x.h?(a-I)/2:(a-(y.height+2*o)*e.scale)/2,M=new Pe(T.x,T.y-A),S=new Pe(T.x+I,T.y),z=new Pe(T.x+I,T.y-A);}else {const t=(y.left-o)*e.scale-g+b[0],i=(-y.top-o)*e.scale+b[1],n=t+A,r=i+I;T=new Pe(t,i),M=new Pe(n,i),S=new Pe(t,r),z=new Pe(n,r);}if(h){let e;e=r?new Pe(0,0):E?new Pe(d[0],d[1]):new Pe(i[0],i[1]),T._rotateAround(h,e),M._rotateAround(h,e),S._rotateAround(h,e),z._rotateAround(h,e);}const R=new Pe(0,0),P=new Pe(0,0);c.push({tl:T,tr:M,bl:S,br:z,texPrimary:n,texSecondary:void 0,writingMode:t.writingMode,glyphOffset:v,sectionIndex:e.sectionIndex,isSDF:l,pixelOffsetTL:R,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0});}}return c}R_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:a="normal",lang:s=null}={}){this.buffer=t,this.radius=i,this.cutoff=n,this.lang=s;const l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${e}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.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:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),s=Math.floor(-r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-s)),u=Math.max(0,Math.min(this.size-this.buffer,a+Math.ceil(n))),c=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(c*h,0),f=new Uint8ClampedArray(d),p={data:f,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:s,glyphAdvance:t};if(0===l||0===u)return p;const{ctx:_,buffer:m,gridInner:g,gridOuter:y}=this;this.lang&&(_.lang=this.lang),_.clearRect(m,m,l,u),_.fillText(e,m-s,m+a);const x=_.getImageData(m,m,l,u);y.fill(w_,0,d),g.fill(0,0,d);let v=3;for(let e=0;e<u;e++){let t=(e+m)*c+m;for(let e=0;e<l;e++,v+=4,t++){const e=x.data[v];if(0===e)continue;const i=E_[e];y[t]=Math.max(0,i),g[t]=Math.max(0,-i);}}A_(y,0,0,c,h,c,this.f,this.v,this.z);const b=Math.min(m,1);A_(g,m-b,m-b,l+2*b,u+2*b,c,this.f,this.v,this.z);const w=255/this.radius,E=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(y[e])-Math.sqrt(g[e]);f[e]=Math.round(E-w*t);}return p}};class k_{constructor(e,t){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=t,this.appearances=e;const i=e.map(e=>function(e){if(!e.condition)return {featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const t=e.condition.expression;return {featureDependent:!Cr(t),stateDependent:!Fr(t),zoomDependent:!Lr(t,["zoom"]),pitchDependent:!Lr(t,["pitch"]),brightnessDependent:!Lr(t,["brightness","measure-light"]),worldviewDependent:!Lr(t,["worldview"])}}(e));this.anyFeatureDependent=i.some(e=>e.featureDependent),this.anyStateDependent=i.some(e=>e.stateDependent);}update(e,t){const i=this.lastParams,n=!i||i.zoom!==e.zoom||i.pitch!==(e.pitch||0)||i.brightness!==(e.brightness||0)||i.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const r=t&&this.anyStateDependent;if(!n&&!r&&-2!==this.lastAllFeaturesIndex)return {kind:"no-changes"};if(!this.anyFeatureDependent&&!r){const t=this.evaluateAllFeatures(e);return t===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=t,{kind:"all-features",appearanceIndex:t})}return {kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;t<this.appearances.length;t++){const i=this.appearances[t];if(i.condition&&i.condition.evaluate(e,void 0,void 0,void 0))return t}return -1}}const U_=Ph.types,G_=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function j_(e,t,i,n,r,o,a,s,l,u,c,h,d){const f=s?Math.min(lf,Math.round(s[0])):0,p=s?Math.min(lf,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,a,(f<<1)+(l?1:0),0+(p<<1),16*u,16*c,256*h,256*d);}function H_(e,t,i){e.emplaceBack(t,i);}function $_(e,t,i,n,r,o,a){e.emplaceBack(t,i,n,r,o,a);}function Z_(e,t,i,n,r){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=n,e.float32[o+2]=r;}function W_(e,t,i,n,r){e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r);}function q_(e){for(const t of e.sections)if(Cs(t.text))return !0;return !1}const X_=12;class Y_{constructor(e){this.layoutVertexArray=new ec,this.indexArray=new uc,this.programConfigurations=e,this.segments=new Uc,this.dynamicLayoutVertexArray=new ic,this.opacityVertexArray=new nc,this.placedSymbolArray=new Mc,this.iconTransitioningVertexArray=new rc,this.globeExtVertexArray=new tc,this.zOffsetVertexArray=new Hu,this.orientationVertexArray=new dc,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Hu,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getBatchGrouping(e){const t=e.get().length===this.segments.get().length;if(t&&this.cachedBatchIndices&&this.cachedBatchSegments)return {batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const i=new Map;for(const t of e.get()){const e=void 0!==t.batchIndex?t.batchIndex:0;i.has(e)||i.set(e,[]),i.get(e).push(t);}const n=Array.from(i.keys()).sort((e,t)=>e-t),r=new Map;for(const e of n){const t=i.get(e);r.set(e,new Uc(t));}return t&&(this.cachedBatchIndices=n,this.cachedBatchSegments=r),{batchIndices:n,batchSegments:r}}snapshotSymbolVertexData(e,t){const i=e*X_;return this.layoutVertexArray.uint16.slice(i,i+t*X_)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*X_);}snapshotIconTransitioningVertexData(e,t){const i=2*e;return this.iconTransitioningVertexArray.uint16.slice(i,i+2*t)}restoreIconTransitioningVertexData(e,t){this.iconTransitioningVertexArray.uint16.set(t,2*e);}updateSymbolVertexData(e,t,i,n,r,o,a,s,l,u,c,h,d){const f=this.layoutVertexArray.uint16,p=e*X_;f[p]=t,f[p+1]=i,f[p+2]=n,f[p+3]=r,f[p+4]=o,f[p+5]=a,f[p+6]=s,f[p+7]=l,f[p+8]=u,f[p+9]=c,f[p+10]=h,f[p+11]=d;}upload(e,t,i,n,r,o){this.isEmpty()||(i&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ed.members,!!o),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Id.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,G_,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,zd.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ad.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Td.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,Sd.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,Md.members,!1))),(i||n)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy());}}qa(Y_,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class J_{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Uc,this.collisionVertexArray=new lc,this.collisionVertexArrayExt=new ic;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Rd.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Pd.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}qa(J_,"CollisionBuffers");class K_{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.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=d([]),this.placementViewportMatrix=d([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.textSizeData=nf(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=nf(this.zoom,t["icon-size"],this.worldview,e.availableImages);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.lut=e.lut,this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>qd[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map;}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return !1;const i=Array.isArray(e)?e:[e];return t.some(e=>i.some(t=>e.hasLayoutProperty(t)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new Y_(new ph(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Y_(new ph(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.text.uboBinder=new $d(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new $d(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.glyphOffsetArray=new Rc,this.lineVertexArray=new Pc,this.symbolInstances=new zc;}calculateGlyphDependencies(e,t,i,n,r){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&r&&e<=65535){const e=Kd[i];e&&(t[e.charCodeAt(0)]=!0);}}}calculateEffectiveAppearanceIconSize(e,t,i,n,r,o,a){if(!e.hasLayoutProperty("icon-size"))return a*o;let s=1;const l=e.getUnevaluatedLayoutProperty("icon-size"),u=nf(this.zoom,l,this.worldview,r),c=of(u,t);if("constant"!==u.kind&&"camera"!==u.kind||(s=c.uSize),"composite"===u.kind){const{minZoom:e,maxZoom:t}=u,o=l.possiblyEvaluate(new Hs(e,{worldview:this.worldview}),n),a=l.possiblyEvaluate(new Hs(t,{worldview:this.worldview}),n),h=o.evaluate(i,{},n,r);s=h+(a.evaluate(i,{},n,r)-h)*c.uSizeT;}return "source"===u.kind&&(s=l.possiblyEvaluate(new Hs(this.zoom,{worldview:this.worldview}),n).evaluate(i,{},n,r)),s*o}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return !Lp(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return "string"==typeof e?Gn.build(e):e}populate(e,t,i,n){const r=this.layers[0],o=r.layout,a="globe"===this.projection.name,s=o.get("text-font"),l=o.get("text-field"),u=o.get("icon-image"),[c,h]=o.get("icon-size-scale-range"),d=tt(t.scaleFactor||1,c,h),[f,p]=o.get("text-size-scale-range"),_=tt(t.scaleFactor||1,f,p),m=("constant"!==l.value.kind||l.value.value instanceof kn&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),g="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,y=this.hasAnyAppearanceLayoutProperty("icon-image"),x=o.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!m&&!g&&!y)return;const v=t.iconDependencies,b=t.glyphDependencies,w=t.availableImages,E=new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),A=e=>{const t=e.id.toString();v.has(t)?v.get(t).push(e):v.set(t,[e]);};for(const t of e){const{feature:e,id:l,index:u,sourceLayerIndex:c}=t,h=r._featureFilter.needGeometry,f=Fu(e,h);if(!r._featureFilter.filter(E,f,i))continue;if(h||(f.geometry=Cu(e,i,n)),a&&1!==e.type&&i.z<=5){const e=f.geometry,t=.98078528056,n=(e,n)=>W(Uf(e.x,e.y,i,1),Uf(n.x,n.y,i,1))<t;for(let t=0;t<e.length;t++)e[t]=zu(e[t],n);}let p,I;if(m){const e=r.getValueAndResolveTokens("text-field",f,i,w),t=kn.factory(e);q_(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Us()||this.hasRTLText&&js.isParsed())&&(p=Wd(t,r,f));}if(g){const e=r.getValueAndResolveTokens("icon-image",f,i,w);I=this.getResolvedImageFromTokens(e);}const T=this.layers[0];let M=!1;if(!I&&y){const e=T.getAppearances();for(const t of e)if(t.getLayoutProperty("icon-image")){const e=T.getAppearanceValueAndResolveTokens(t,"icon-image",f,i,w);if(e){I=this.getResolvedImageFromTokens(e),M=!0;break}}}if(!p&&!I)continue;const S=this.sortFeaturesByKey?x.evaluate(f,{},i):void 0,z={id:l,text:p,icon:I,index:u,sourceLayerIndex:c,geometry:f.geometry,properties:e.properties,type:U_[e.type],sortKey:S};if(this.features.push(z),this.featureAppearanceData.set(u,{id:l,properties:e.properties,usesAppearanceIconAsPlaceholder:M}),I){const e=T._unevaluatedLayout._values,{iconPrimary:t,iconSecondary:n}=ff(I,this.iconSizeData,e["icon-size"],i,this.zoom,z,this.pixelRatio,d,this.worldview,w);A(t),n&&(this.hasAnySecondaryIcon=!0,A(n));}const R=T.getAppearances();if(0!==R.length&&R.forEach(e=>{if(!e.getLayoutProperty("icon-image"))return;const{iconPrimary:t,iconSecondary:n}=this.getCombinedIconVariants(e,T,f,i,w,z,d);t&&(A(t),n&&(this.hasAnySecondaryIcon=!0,A(n)));}),p){const e=s.evaluate(f,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(qd.vertical);for(const i of p.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio*_),t=e.id.toString(),n=v.get(t)||[];n.push(e),v.set(t,n);}else {const n=Ms(p.toString()),r=i.fontStack||e,o=b[r]=b[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n);}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++;}function a(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function s(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0].at(-1):t[0][0];return `${e}:${n.x}:${n.y}`}for(let u=0;u<e.length;u++){const c=e[u],h=c.geometry,d=c.text?c.text.toString():null;if(!d||h.length>1){o(u);continue}const f=l(d,h,!1),p=l(d,h,!0);if(f in i&&p in t&&i[f]!==t[p]){const e=s(f,p,h),r=a(f,p,n[e].geometry);delete t[f],delete i[p],i[l(d,n[r].geometry,!0)]=r,n[e].geometry=null;}else f in i?a(f,p,h):p in t?s(f,p,h):(o(u),t[f]=r-1,i[p]=r-1);}return n.filter(e=>e.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")?(this.elevationType="road",this.hdExt&&(this.hdExt.configureCrossSource(i,t.elevationParams,t.crossSourceElevationEnabled,t.terrainEnabled),t.elevationFeatures&&t.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(t.elevationFeatures,i))):o.get("symbol-z-elevate")&&(this.elevationType="offset"),"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey);}getCombinedIconVariants(e,t,i,n,r,o,a){let s;if(e.hasLayoutProperty("icon-image")){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,n,r);s=this.getResolvedImageFromTokens(o);}else {const e=t.getValueAndResolveTokens("icon-image",i,n,r);s=this.getResolvedImageFromTokens(e);}if(s){const i=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],l=nf(this.zoom,i,this.worldview,r),{iconPrimary:u,iconSecondary:c}=ff(s,l,i,n,this.zoom,o,this.pixelRatio,a,this.worldview,r);return {iconPrimary:u,iconSecondary:c}}return {iconPrimary:void 0,iconSecondary:void 0}}getCombinedIconPrimary(e,t,i,n,r,o,a){return this.getCombinedIconVariants(e,t,i,n,r,o,a).iconPrimary}updateSymbolInstanceIconVertices(e,t,i,n,r,o){const{canonical:a,availableImages:s,globalProperties:l,layer:u,iconScaleFactor:c,featureState:h,layoutIconOffset:d,layoutIconSize:f,layoutIconRotate:p}=o;if(e.placedIconSymbolIndex<0)return {vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===i)return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const _=i>=0?u.appearances[i]:null;if(_){const i={sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},{iconPrimary:o,iconSecondary:m}=this.getCombinedIconVariants(_,u,n,a,s,i,c);if(!o)return {vertexOffsetDelta:0,hasChanges:!1};const g=o.toString(),y=this.iconAtlasPositions&&this.iconAtlasPositions.get(g);if(y){const{appearanceIconOffset:i,appearanceIconRotate:o}=cf(_,u,n,a,d,p,f,c),g=u.layout.get("icon-anchor").evaluate(n,h,a);let x=Yd(y,m?this.iconAtlasPositions&&this.iconAtlasPositions.get(m.toString()):void 0,i,g);const v=y.sdf,b=u.layout.get("icon-text-fit").constantOr("none");"none"!==b&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(x=Jd(x,t.textShaping,b,t.iconTextFitPadding,i,t.fontScale));const w=this.calculateEffectiveAppearanceIconSize(_,l.zoom,n,a,s,c,f),E=0,A=1+(Math.min(lf,Math.round(w*tf))<<1),I=D_(x,o,v,"none"!==b,c),T=this.icon.iconTransitioningVertexArray.length>0;t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(r,e.numIconVertices),T&&(t.layoutBasedIconTransitioningVertexData=this.icon.snapshotIconTransitioningVertexData(r,e.numIconVertices)));const M=Math.floor(e.numIconVertices/4),S=Math.min(I.length,M);let z=r;const R=T?this.icon.iconTransitioningVertexArray.uint16:null;for(let i=0;i<S;++i){const n=I[i],r=t.layoutBasedIconVertexData[0]||e.tileAnchorX,o=t.layoutBasedIconVertexData[1]||e.tileAnchorY,a=16*n.pixelOffsetTL.x,s=16*n.pixelOffsetTL.y,l=16*n.pixelOffsetBR.x,u=16*n.pixelOffsetBR.y,c=16*n.minFontScaleX,h=16*n.minFontScaleY;if(this.icon.updateSymbolVertexData(z,r,o,Math.round(32*n.tl.x),Math.round(32*n.tl.y),n.texPrimary.x,n.texPrimary.y,E,A,a,s,c,h),this.icon.updateSymbolVertexData(z+1,r,o,Math.round(32*n.tr.x),Math.round(32*n.tr.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y,E,A,l,s,c,h),this.icon.updateSymbolVertexData(z+2,r,o,Math.round(32*n.bl.x),Math.round(32*n.bl.y),n.texPrimary.x,n.texPrimary.y+n.texPrimary.h,E,A,a,u,c,h),this.icon.updateSymbolVertexData(z+3,r,o,Math.round(32*n.br.x),Math.round(32*n.br.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y+n.texPrimary.h,E,A,l,u,c,h),R){const e=n.texSecondary?n.texSecondary:n.texPrimary,t=2*z;R[t]=e.x,R[t+1]=e.y,R[t+2]=e.x+e.w,R[t+3]=e.y,R[t+4]=e.x,R[t+5]=e.y+e.h,R[t+6]=e.x+e.w,R[t+7]=e.y+e.h;}z+=4;}const P=e.numIconVertices-4*S;for(let e=0;e<P;++e)this.icon.updateSymbolVertexData(z+e,0,0,0,0,0,0,0,0,0,0,0,0);return {vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else {if(t.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(r,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(t.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(r,t.layoutBasedIconVertexData),t.layoutBasedIconTransitioningVertexData&&this.icon.restoreIconTransitioningVertexData(r,t.layoutBasedIconTransitioningVertexData),t.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:t.layoutBasedIconVertexData.length/X_,hasChanges:!0}}return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,t,i,n,r,o){const{canonical:a,layer:s,textScaleFactor:l,imageMap:u,featureState:c,layoutTextOffset:h,layoutTextSize:d,layoutTextRotate:f,layoutMinZoomSize:p,layoutMaxZoomSize:_,layoutTextSizeMinZoom:m,layoutTextSizeMaxZoom:g,availableImages:y}=o,x=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!x)return {vertexOffsetDelta:x?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===i)return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const v=i>=0?s.appearances[i]:null;if(v&&t.textShaping){const{appearanceTextOffset:i,appearanceTextRotate:o,appearanceTextSize:x}=hf(v,s,n,a,h,f,d);t.fontScale=pf(x,t.textScaleFactor);const b=v.getUnevaluatedLayoutProperty("text-size");let w=this.textSizeData,E=m,A=g;v.hasLayoutProperty("text-size")&&(w=nf(this.zoom,b,this.worldview,y),E="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,A="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const I=t.textShaping.bottom-h[1],T=t.textShaping.left-h[0],M=t.textShaping.right-h[0];t.textShaping.top=i[1]+(t.textShaping.top-h[1]),t.textShaping.bottom=i[1]+I,t.textShaping.left=i[0]+T,t.textShaping.right=i[0]+M;const S=V_(0,t.textShaping,i,s,!1,n,u,this.allowVerticalPlacement,o),z=x&&"composite"===w.kind?b.possiblyEvaluate(new Hs(E,{}),a).evaluate(n,c,a):p,R=x&&"composite"===w.kind?b.possiblyEvaluate(new Hs(A,{}),a).evaluate(n,c,a):_,P=_f(v.name,w,x,l,z,R),D=Array.isArray(P)?P[1]:x,C=0,F=1+(Math.min(lf,Math.round(D*tf))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(r,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t<S.length&&t<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++t){const i=S[t],n=i.glyphOffset[1],o=e.tileAnchorX,a=e.tileAnchorY,s=r+4*t;this.text.updateSymbolVertexData(s,o,a,Math.round(32*i.tl.x),Math.round(32*(n+i.tl.y)),i.texPrimary.x,i.texPrimary.y,C,F,i.pixelOffsetTL.x,i.pixelOffsetTL.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(s+1,o,a,Math.round(32*i.tr.x),Math.round(32*(n+i.tr.y)),i.texPrimary.x+i.texPrimary.w,i.texPrimary.y,C,F,i.pixelOffsetBR.x,i.pixelOffsetTL.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(s+2,o,a,Math.round(32*i.bl.x),Math.round(32*(n+i.bl.y)),i.texPrimary.x,i.texPrimary.y+i.texPrimary.h,C,F,i.pixelOffsetTL.x,i.pixelOffsetBR.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(s+3,o,a,Math.round(32*i.br.x),Math.round(32*(n+i.br.y)),i.texPrimary.x+i.texPrimary.w,i.texPrimary.y+i.texPrimary.h,C,F,i.pixelOffsetBR.x,i.pixelOffsetBR.y,i.minFontScaleX,i.minFontScaleY);}return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return t.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(r,t.layoutBasedTextVertexData),t.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:t.layoutBasedTextVertexData.length/X_,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(e){this.text&&this.text.programConfigurations.updateExpressions(e),this.icon&&this.icon.programConfigurations.updateExpressions(e);}update(e,t,i,n,r,o,a,s){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,this.worldview),s)if(o)for(const n of [this.text.uboBinder,this.icon.uboBinder])n&&!n.isLightConstant&&n.updateDynamicExpressions(r[0],t,s,i,e,a);else if(Object.keys(e).length>0){const n=r[0],o=[this.text.uboBinder,this.icon.uboBinder].filter(e=>e&&e.hasStateDependentPaint(n));if(o.length>0){const r=new Set(Object.keys(e).map(e=>{const t=Number(e);return !isNaN(t)&&Number.isSafeInteger(t)&&String(t)===e?t:e}));for(const l of o)l.updateFeatures(r,n,t,s,i,e,a);}}}updateZOffset(){const e=(e,t,n)=>{i+=t,i>e.length&&e.resize(i);for(let r=-t;r<0;r++)e.emplace(r+i,n);},t=(e,t,i)=>{n+=t,n>e.length&&e.resize(n);for(let r=-t;r<0;r++)e.emplace(r+n,i);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,n=0;for(let i=0;i<this.symbolInstances.length;i++){const n=this.symbolInstances.get(i),{numHorizontalGlyphVertices:r,numVerticalGlyphVertices:o,numIconVertices:a}=n,s=n.zOffset,l=a>0;if((r>0||o>0)&&(e(this.text.zOffsetVertexArray,r,s),e(this.text.zOffsetVertexArray,o,s)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=n;e>=0&&t(this.icon.zOffsetVertexArray,a,s),i>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,s);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,i,n,r){!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.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0;}updateAppearances(e,t,i,n,r,o=!1){const a={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!i||!this.featureAppearanceData)return a;const s=t||{},l=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,u=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!l&&!u)return a;const c=this.layers[0],h=c.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===c.appearancesVersion||(this.featureAppearances=new k_(c.appearances,c.appearancesVersion));const d=this.featureAppearances.update(n,o);if("no-changes"===d.kind)return a;let f=1,p=0,_=!1,m=!1;if(l){const[e,t]=h.get("icon-size-scale-range");f=tt(1,e,t);}let g=1,y=0,x=!1;if(u){const[e,t]=h.get("text-size-scale-range");g=tt(1,e,t);}const v=new Map;if(r&&i)for(const e of i){const t=r.getImage(e,c.scope);if(t){const i=new Un(e.toString());v.set(i.toString(),t);}}const b=[this.text.uboBinder,this.icon.uboBinder];for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t),o=this.getAppearanceFeatureData(r.featureIndex);if(!o)continue;const a=o.id,w=void 0!==a?s[String(a)]:void 0,E={type:"Point",id:o.id,properties:o.properties,geometry:[]};let A;if("all-features"===d.kind)A=d.appearanceIndex;else {const t=c.appearances?c.appearances.findIndex(t=>t.isActive({globals:n,feature:E,canonical:e,featureState:w})):-1;A=t>=0?t:-1;}const I=o.activeAppearanceIndex!==A;if(u){const t=h.get("text-size"),n="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,a="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,s={canonical:e,layer:c,featureState:w,availableImages:i,textScaleFactor:g,imageMap:v,layoutTextOffset:h.get("text-offset").evaluate(E,w,e).map(e=>e*Zd),layoutTextSize:t.evaluate(E,w,e),layoutTextRotate:h.get("text-rotate").evaluate(E,w,e),layoutMinZoomSize:t.evaluate(E,{zoom:n},e),layoutMaxZoomSize:t.evaluate(E,{zoom:a},e),layoutTextSizeMinZoom:n,layoutTextSizeMaxZoom:a},l=this.updateSymbolInstanceTextVertices(r,o,A,E,y,s);y+=l.vertexOffsetDelta,x=x||l.hasChanges;}if(l){const t={canonical:e,layer:c,featureState:w,availableImages:i,globalProperties:n,iconScaleFactor:f,layoutIconOffset:h.get("icon-offset").evaluate(E,w,e),layoutIconSize:h.get("icon-size").evaluate(E,w,e,i),layoutIconRotate:h.get("icon-rotate").evaluate(E,w,e)},a=this.updateSymbolInstanceIconVertices(r,o,A,E,p,t);p+=a.vertexOffsetDelta,_=_||a.hasChanges;}if(I){const t=r.featureIndex,o=n?n.brightness:null,a=w||{},s=A>=0?c.appearances[A]:null;for(const n of b)n&&(n.layer=c,m=n.updateFeaturePaintForAppearance(t,E,a,e,i,o,s)||m);}o.activeAppearanceIndex=A;}return _&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),_&&this.icon.iconTransitioningVertexBuffer&&this.icon.iconTransitioningVertexArray.length>0&&this.icon.iconTransitioningVertexArray.length===this.icon.iconTransitioningVertexBuffer.length&&this.icon.iconTransitioningVertexBuffer.updateData(this.icon.iconTransitioningVertexArray),x&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:_||x,hasUboChanges:m}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=zp(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return {lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g){const y=e.indexArray,x=e.layoutVertexArray,v=e.globeExtVertexArray,b=g,w=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,E=e.segments.prepareSegment(4*b,x,y,this.canOverlap?o.sortKey:void 0,w),A=this.glyphOffsetArray.length,I=E.vertexLength,T=this.allowVerticalPlacement&&a===qd.vertical?Math.PI/2:0,M=o.text&&o.text.sections;let S=x.length,z=-1;for(let n=0;n<t.length;n++){const{tl:r,tr:a,bl:u,br:c,texPrimary:h,texSecondary:m,pixelOffsetTL:g,pixelOffsetBR:b,minFontScaleX:w,minFontScaleY:A,glyphOffset:I,isSDF:R,sectionIndex:P}=t[n],D=E.vertexLength,C=I[1];if(j_(x,l.x,l.y,r.x,C+r.y,h.x,h.y,i,R,g.x,g.y,w,A),j_(x,l.x,l.y,a.x,C+a.y,h.x+h.w,h.y,i,R,b.x,g.y,w,A),j_(x,l.x,l.y,u.x,C+u.y,h.x,h.y+h.h,i,R,g.x,b.y,w,A),j_(x,l.x,l.y,c.x,C+c.y,h.x+h.w,h.y+h.h,i,R,b.x,b.y,w,A),s){const{x:t,y:i,z:n}=s.anchor,[r,o,a]=s.up;$_(v,t,i,n,r,o,a),$_(v,t,i,n,r,o,a),$_(v,t,i,n,r,o,a),$_(v,t,i,n,r,o,a),W_(e.dynamicLayoutVertexArray,t,i,n,T);}else W_(e.dynamicLayoutVertexArray,l.x,l.y,l.z,T);if(_){const t=m||h;H_(e.iconTransitioningVertexArray,t.x,t.y),H_(e.iconTransitioningVertexArray,t.x+t.w,t.y),H_(e.iconTransitioningVertexArray,t.x,t.y+t.h),H_(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h);}if(y.emplaceBack(D,D+1,D+2),y.emplaceBack(D+1,D+2,D+3),E.vertexLength+=4,E.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(I[0]),(n===t.length-1||P!==t[n+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(x.length,o,o.index,{},d,f,p,M&&M[P],this.worldview),e.uboBinder)){const t=e.uboBinder.populateUBO(o,o.index,f,d,p,M&&M[P]);z=t;const i=x.length-S;for(let n=0;n<i;n++)e.featureIdArray.emplaceBack(t);S=x.length;}}const R=g-t.length;if(0!==R&&(this._addNullVertices(R,x,i,s,v,e,_,E,y),e.uboBinder&&z>=0)){const t=4*R;for(let i=0;i<t;i++)e.featureIdArray.emplaceBack(z);}const P=s?s.anchor:l;e.placedSymbolArray.emplaceBack(P.x,P.y,P.z,l.x,l.y,A,this.glyphOffsetArray.length-A,I,u,c,l.segment,i?i[0]:0,i?i[1]:0,n[0],n[1],a,0,0,0,h,0),e.symbolInstanceIndices.push(m);}_addNullVertices(e,t,i,n,r,o,a,s,l){for(let u=0;u<e;u++){for(let e=0;e<4;e++)j_(t,0,0,0,0,0,0,i,!1,0,0,0,0),n?($_(r,0,0,0,0,0,0),W_(o.dynamicLayoutVertexArray,0,0,0,0)):W_(o.dynamicLayoutVertexArray,0,0,0,0),a&&H_(o.iconTransitioningVertexArray,0,0);const e=s.vertexLength;l.emplaceBack(e,e+1,e+2),l.emplaceBack(e+1,e+2,e+3),s.vertexLength+=4,s.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0);}}_commitLayoutVertex(e,t,i,n,r,o,a){e.emplaceBack(t,i,n,r,o,Math.round(a.x),Math.round(a.y));}_addCollisionDebugVertices(e,t,i,n,r,o,a){const s=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=s.vertexLength,u=a.tileAnchorX,c=a.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,t,e.padding,a.zOffset),this._commitLayoutVertex(i.layoutVertexArray,n,r,o,u,c,new Pe(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,r,o,u,c,new Pe(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,r,o,u,c,new Pe(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,n,r,o,u,c,new Pe(e.x1,e.y2)),s.vertexLength+=4;const h=i.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),s.primitiveLength+=4;}_addTextDebugCollisionBoxes(e,t,i,n,r,o){for(let a=n;a<r;a++){const n=i.get(a),r=this.getSymbolInstanceTextSize(e,o,t,a);this._addCollisionDebugVertices(n,r,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o);}}_addIconDebugCollisionBoxes(e,t,i,n,r,o){for(let a=n;a<r;a++){const n=i.get(a),r=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._addCollisionDebugVertices(n,r,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o);}}generateCollisionDebugBuffers(e,t,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new J_(ac,Dd.members,rc),this.iconCollisionBox=new J_(ac,Dd.members,rc);const n=of(this.iconSizeData,e),r=of(this.textSizeData,e,i);for(let i=0;i<this.symbolInstances.length;i++){const o=this.symbolInstances.get(i);this._addTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o);}}getSymbolInstanceTextSize(e,t,i,n){const r=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=rf(this.textSizeData,e,r)/Zd;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=rf(this.iconSizeData,e,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(e,t,i,n){e.emplaceBack(t,-i,-i,n),e.emplaceBack(t,i,-i,n),e.emplaceBack(t,i,i,n),e.emplaceBack(t,-i,i,n);}_updateTextDebugCollisionBoxes(e,t,i,n,r,o,a){for(let a=n;a<r;a++){const n=i.get(a),r=this.getSymbolInstanceTextSize(e,o,t,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,r,n.padding,o.zOffset);}}_updateIconDebugCollisionBoxes(e,t,i,n,r,o,a){for(let a=n;a<r;a++){const n=i.get(a),r=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,r,n.padding,o.zOffset);}}updateCollisionDebugBuffers(e,t,i,n){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const r=of(this.iconSizeData,e,n),o=of(this.textSizeData,e,i);for(let a=0;a<this.symbolInstances.length;a++){const s=this.symbolInstances.get(a);this._updateTextDebugCollisionBoxes(o,e,t,s.textBoxStartIndex,s.textBoxEndIndex,s,i),this._updateTextDebugCollisionBoxes(o,e,t,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s,i),this._updateIconDebugCollisionBoxes(r,e,t,s.iconBoxStartIndex,s.iconBoxEndIndex,s,n),this._updateIconDebugCollisionBoxes(r,e,t,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s,n);}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);}_deserializeCollisionBoxesForSymbol(e,t,i,n,r,o,a,s,l){const u={};if(t<i){const{x1:i,y1:n,x2:r,y2:o,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:f}=e.get(t);u.textBox={x1:i,y1:n,x2:r,y2:o,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.textFeatureIndex=f;}if(n<r){const{x1:t,y1:i,x2:r,y2:o,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:f}=e.get(n);u.verticalTextBox={x1:t,y1:i,x2:r,y2:o,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.verticalTextFeatureIndex=f;}if(o<a){const{x1:t,y1:i,x2:n,y2:r,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:f}=e.get(o);u.iconBox={x1:t,y1:i,x2:n,y2:r,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.iconFeatureIndex=f;}if(s<l){const{x1:t,y1:i,x2:n,y2:r,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:f}=e.get(s);u.verticalIconBox={x1:t,y1:i,x2:n,y2:r,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.verticalIconFeatureIndex=f;}return u}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<n;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),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),n=[],r=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const a=this.symbolInstances.get(e);n.push(0|Math.round(t*a.tileAnchorX+i*a.tileAnchorY)),r.push(a.featureIndex);}return o.sort((e,t)=>n[e]-n[t]||r[t]-r[e]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e);}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const i=this.sortKeyRanges.at(-1);i&&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)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesByY=!1;else {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{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:s}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}qa(K_,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),K_.addDynamicAttributes=W_;class Q_ extends vh{constructor(e,t,i){super(e,t,i),this.elevatedLayoutVertexArray=new Hu;}upload(e){const t=this.uploaded;super.upload(e),!t&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Nc.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy();}}qa(Q_,"ElevatedFillBufferData");class em{constructor(){this.portals=[];}static isOnBorder(e,t){return e<=0&&t<=0||e>=Sr&&t>=Sr}static evaluate(e){if(0===e.length)return new em;let t=[];for(const i of e)t.push(...i.portals);if(0===t.length)return new em;for(const e of t){const t=e.va,i=e.vb;(em.isOnBorder(t.x,i.x)||em.isOnBorder(t.y,i.y))&&(e.type="border");}const i=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new em;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hash<t.hash?1:-1),t=i.concat(n);let r=i.length,o=r,a=r;do{if(o++,o===t.length||t[r].hash!==t[o].hash){if(o-r===2){a<r&&(t[a]=t[r],t[r]=null);const e=t[a],i=t[o-1];e.type=e.isTunnel!==i.isTunnel?"tunnel":"polygon",e.connection={a:e.connection.a,b:i.connection.a},a++;}r=o;}}while(r!==t.length);return t.splice(a),t.sort((e,t)=>e.hash<t.hash?1:-1),{portals:t}}}qa(em,"ElevationPortalGraph");class tm{constructor(e,t,i){this.outPositions=e,this.outNormals=t,this.outIndices=i,this.vertexLookup=new Map;}addVertex(e,t,i){let n=e[2];null!=i&&(n*=i);const r=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,o=this.vertexLookup.get(r);if(null!=o)return o;const a=this.outPositions.length;this.vertexLookup.set(r,a);const s=Math.trunc(16384*t[0]),l=Math.trunc(16384*t[1]),u=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],n),this.outNormals.emplaceBack(s,l,u),a}addTriangle(e,t,i){this.outIndices.emplaceBack(e,t,i);}addTriangles(e,t,i,n=0){if(0===e.length)return;const r=R(),o=R();for(let a=0;a<e.length;a+=3){const s=t[e[a+0]],l=t[e[a+1]],u=t[e[a+2]],c=i[e[a+1]]+n,h=i[e[a+2]]+n;F(r,s.x,s.y,i[e[a+0]]+n);const d=this.addVertex(r,o);F(r,l.x,l.y,c);const f=this.addVertex(r,o);F(r,u.x,u.y,h);const p=this.addVertex(r,o);this.outIndices.emplaceBack(d,f,p);}}addQuad(e,t,i,n,r,o){const a=this.addVertex(e,r,o),s=this.addVertex(t,r,o),l=this.addVertex(i,r,o),u=this.addVertex(n,r,o);this.addTriangle(a,s,l),this.addTriangle(l,u,a);}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear();}}class im{constructor(e,t,i,n){this.unevaluatedPortals=new em,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new $u,this.vertexNormals=new Zu,this.indexArray=new uc,this.tileToMeters=Au(e),this.bridgeProgramConfigurations=new ph(t,{zoom:i,lut:n},e=>"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new ph(t,{zoom:i,lut:n},e=>"fill-bridge-guard-rail-color"!==e);}addVertices(e,t){const i=this.unevalVertices.length;for(let i=0;i<e.length;i++)this.unevalVertices.push(e[i]),this.unevalHeights.push(t[i]);return i}addTriangles(e,t,i){const n=i?this.unevalTunnelTriangles:this.unevalTriangles;for(const i of e)n.push(i+t);}addRenderableRing(e,t,i,n,r,o){const a=[new Pe(r.min.x,r.min.y),new Pe(r.max.x,r.min.y),new Pe(r.max.x,r.max.y),new Pe(r.min.x,r.max.y)];for(let s=0;s<i-1;s++){const i=t+s,l=i+1,u=this.unevalVertices[i],c=this.unevalVertices[l];if(!(u.x>=r.min.x&&u.x<=r.max.x&&u.y>=r.min.y&&u.y<=r.max.y||c.x>=r.min.x&&c.x<=r.max.x&&c.y>=r.min.y&&c.y<=r.max.y||Xh(u,c,a)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=im.computeEdgeHash(this.unevalVertices[i],this.unevalVertices[l]);let d,f=this.vertexHashLookup.get(im.computePosHash(u));null!=f?d=f.next:(f=this.vertexHashLookup.get(im.computePosHash(c)),d=null!=f?f.prev:h),this.unevalEdges.push({polygonIdx:e,a:i,b:l,hash:h,portalHash:d,isTunnel:n,type:"unevaluated",featureInfo:o});}}addPortalCandidates(e,t,i,n,r){if(0!==t.length){this.vertexHashLookup.clear();for(const r of t){if(0===r.length)continue;const t=r[0];let o=im.computeEdgeHash(t[t.length-2],t.at(-1));for(let r=0;r<t.length-1;r++){const a=t[r+0],s=t[r+1],l=be(s.x-a.x,s.y-a.y),u=Te(l);if(0===u)continue;let c="unevaluated";const h=n.pointElevation(a),d=n.pointElevation(s);Math.abs(h)<.01&&Math.abs(d)<.01?c="entrance":(this.isOnBorder(a.x,s.x)||this.isOnBorder(a.y,s.y))&&(c="border");const f=im.computeEdgeHash(a,s);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:a,vb:s,vab:l,length:u,hash:f,isTunnel:i,type:c});const p=im.computePosHash(a);this.vertexHashLookup.has(p)||this.vertexHashLookup.set(p,{prev:o,next:f}),o=f;}}}}construct(e){if(0===this.unevalVertices.length)return;const t=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),i=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset;},n=new tm(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const r=t(),o=t(),a=t(),s=(e,t)=>{e.sort((e,i)=>e.type===t&&i.type!==t?-1:e.type!==t&&i.type===t?1:0);const i=e.findIndex(e=>e.type!==t);return i>=0?i:e.length};let l=0;this.unevalEdges.length>0&&(l=s(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),i(a);const u=t(),c=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=s(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t});}i(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),i(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),i(o),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),i(r),this.maskSegments=Uc.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=Uc.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=Uc.simpleSegment(0,a.primitiveOffset,0,a.primitiveLength),this.renderableTunnelSegments=Uc.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=Uc.simpleSegment(0,r.primitiveOffset,0,r.primitiveLength);}update(e,t,i,n,r,o,a,s){this.bridgeProgramConfigurations.updatePaintArrays(e,t,r,i,n,o,a,s),this.tunnelProgramConfigurations.updatePaintArrays(e,t,r,i,n,o,a,s);}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Vc.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,kc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e));}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy();}populatePaintArrays(e,t,i,n,r){const o=(o,a)=>{for(let s=0;s<a.length-1;s++){const l=a[s].featureIndex,u=a[s+1].vertexStart,c=e.feature(l);o.populatePaintArrays(u,c,l,{},i,t,n,void 0,r);}};o(this.bridgeProgramConfigurations,this.bridgeFeatureSections),o(this.tunnelProgramConfigurations,this.tunnelFeatureSections);}computeVertexConnections(e,t,i,n,r){const o=new Map;for(let a=n;a<r;a++){const n=i[a],r=n.a,s=n.b,l=im.computePosHash(e[r]),u=im.computePosHash(e[s]);let c=o.get(l);c||(c={},o.set(l,c));let h=o.get(u);h||(h={},o.set(u,h)),t[r]<=0&&t[s]<=0||(c.to=s,h.from=r);}return o}isTerminalVertex(e,t){const i=im.computePosHash(this.unevalVertices[e]),n=t.get(i);return !n||!n.from||!n.to}constructBridgeStructures(e,t,i,n,r,o){e.clearVertexLookup();const a=this.computeVertexConnections(t,i,n,r.min,r.max),s=1/o,l=.5*s,u=(e,n)=>F(e,t[n].x,t[n].y,i[n]*s),c=R(),h=R(),d=R(),f=R(),p=R(),_=(e,i)=>{const n=a.get(im.computePosHash(t[i])),r=n.from,o=n.to;if(!r||!o)return;u(c,r),u(h,i),u(d,o),Q(f),ee(c,h)||(te(p,h,c),Z(f,p)),ee(d,h)||(te(p,d,h),O(f,f,Z(p,p)));const s=ne(f);return s>0?k(e,f,1/s):void 0};let m=Number.POSITIVE_INFINITY;this.sortSubarray(n,r.min,r.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const g=R(),y=R(),x=R(),v=R(),b=R(),w=R(),E=R(),A=R(),I=R(),T=[R(),R(),R(),R()],M=[R(),R(),R(),R()],S=[{coord:new Pe(0,0),height:0},{coord:new Pe(0,0),height:0}],z=(e,t)=>e>t;for(let u=r.min;u<r.max;u++){const r=n[u];if(!r.featureInfo.guardRailEnabled)continue;if(!this.prepareEdgePoints(S,t,i,r,z))continue;const[c,h]=S;if(F(g,c.coord.x,c.coord.y,s*c.height),F(y,h.coord.x,h.coord.y,s*h.height),ee(g,y))continue;te(x,y,g),Z(x,x);const d=_(A,r.a)||x,f=_(I,r.b)||x;F(v,d[1],-d[0],0),Z(v,v),F(b,f[1],-f[0],0),Z(b,b),q(A,v,d),Z(w,A),q(A,b,f),Z(E,A),O(T[0],g,k(A,te(A,v,w),l)),O(T[1],g,k(A,O(A,v,w),l)),O(T[2],g,k(A,w,l)),T[3]=g,O(M[0],y,k(A,te(A,b,E),l)),O(M[1],y,k(A,O(A,b,E),l)),O(M[2],y,k(A,E,l)),M[3]=y,m=this.addFeatureSection(r.featureInfo.featureIndex,m,this.bridgeFeatureSections,e);const p=e.addVertex(T[0],v,o),R=e.addVertex(T[1],v,o),P=e.addVertex(M[0],b,o),D=e.addVertex(M[1],b,o);e.addTriangle(p,R,P),e.addTriangle(R,D,P);const C=e.addVertex(T[1],w,o),L=e.addVertex(T[2],w,o),B=e.addVertex(M[1],E,o),N=e.addVertex(M[2],E,o);e.addTriangle(C,L,B),e.addTriangle(L,N,B),$(v,v),$(b,b);const V=e.addVertex(T[2],v,o),U=e.addVertex(T[3],v,o),G=e.addVertex(M[2],b,o),j=e.addVertex(M[3],b,o);e.addTriangle(V,U,G),e.addTriangle(U,j,G);const H=this.isTerminalVertex(r.a,a),W=this.isTerminalVertex(r.b,a);c.height<.01&&H&&e.addQuad(T[3],T[2],T[1],T[0],$(d,d),o),h.height<.01&&W&&e.addQuad(M[0],M[1],M[2],M[3],f,o);}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()});}constructTunnelStructures(e,t,i,n,r,o){e.clearVertexLookup();let a=Number.POSITIVE_INFINITY;const s=(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,r.min,r.max,s),this.sortSubarray(n,o.min,o.max,s);const l=e=>Z(e,e),u=[{coord:new Pe(0,0),height:0},{coord:new Pe(0,0),height:0}],c=(e,t)=>e<t,h=R(),d=R(),f=R(),p=R(),_=R();for(let o=r.min;o<r.max;o++){if(!this.prepareEdgePoints(u,t,i,n[o],c))continue;const[r,s]=u,m=l(F(_,-(s.coord.y-r.coord.y),s.coord.x-r.coord.x,0));a=this.addFeatureSection(n[o].featureInfo.featureIndex,a,this.tunnelFeatureSections,e),e.addQuad(F(h,r.coord.x,r.coord.y,r.height),F(d,s.coord.x,s.coord.y,s.height),F(f,s.coord.x,s.coord.y,n[o].isTunnel?s.height+4:0),F(p,r.coord.x,r.coord.y,n[o].isTunnel?r.height+4:0),m);}for(let r=o.min;r<o.max;r++){const o=n[r];o.isTunnel&&([o.a,o.b]=[o.b,o.a]);const s=t[o.a],u=t[o.b],c=l(F(_,-(u.y-s.y),u.x-s.x,0));a=this.addFeatureSection(o.featureInfo.featureIndex,a,this.tunnelFeatureSections,e),e.addQuad(F(h,u.x,u.y,0),F(d,s.x,s.y,0),F(f,s.x,s.y,i[o.a]+4),F(p,u.x,u.y,i[o.b]+4),c),e.addQuad(F(h,s.x,s.y,0),F(d,u.x,u.y,0),F(f,u.x,u.y,i[o.b]+4),F(p,s.x,s.y,i[o.a]+4),c);}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()});}setElevatedPoint(e,t,i,n){e.coord.x=t,e.coord.y=i,e.height=n;}prepareEdgePoints(e,t,i,n,r){let o=t[n.a].x,a=t[n.a].y,s=t[n.b].x,l=t[n.b].y,u=i[n.a],c=i[n.b];const h=r(u,0),d=r(c,0);if(h&&d)return this.setElevatedPoint(e[0],o,a,u),this.setElevatedPoint(e[1],s,l,c),!0;if(!h&&!d)return !1;if(h){if(!d){const e=c/(c-u);s=dn(s,o,e),l=dn(l,a,e),c=dn(c,u,e);}}else {const e=u/(u-c);o=dn(o,s,e),a=dn(a,l,e),u=dn(u,c,e);}return this.setElevatedPoint(e[0],o,a,u),this.setElevatedPoint(e[1],s,l,c),!0}prepareEdges(e,t){if(0===t.length)return;t.sort((e,t)=>e.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let i=0,n=0,r=0,o=t[i].polygonIdx;do{n++,(n===t.length||t[i].hash!==t[n].hash)&&((1===n-i||t[n-1].polygonIdx!==o)&&(r<i&&(t[r]=t[i],t[i]=null),t[r].type="none",r++),i=n,i!==t.length&&(o=t[i].polygonIdx));}while(i!==t.length);if(t.splice(r),0!==t.length&&0!==e.length){t.sort((e,t)=>e.portalHash<t.portalHash?1:-1);let i=0,n=0;for(;i!==t.length&&n!==e.length;){const r=t[i],o=e[n];r.portalHash>o.hash?i++:o.hash>r.portalHash?n++:(r.type=o.type,i++);}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Sr&&t>=Sr}addFeatureSection(e,t,i,n){return e!==t&&(t=e,i.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,i,n){const r=e.slice(t,i);r.sort(n),e.splice(t,r.length,...r);}static computeEdgeHash(e,t){return (e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(im.computePosHash(e))<<32n|BigInt(im.computePosHash(t))}static computePosHash(e){return ((65535&e.x)<<16|65535&e.y)>>>0}}class nm{constructor(){this._valid=!1;}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,i){return this.get(e,!0,t,i)}optional(e,t,i){return this.get(e,!1,t,i)}success(){return this._valid}get(e,t,i,n){const r=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==r&&!Number.isNaN(r)?i(n?n(r):r):t&&(this._valid=!1),this}}class rm{constructor(e,t){this.featureFunc=e,this.vertexFunc=t;}parseFeature(e,t,i){return this.featureFunc(e,t,i)}parseVertex(e,t,i){return this.vertexFunc(e,t,i)}}const om=new rm((e,t,i)=>e.reset(t).require(dd,e=>{i.id=e;}).optional("fixed_height_relative",e=>{i.constantHeight=e;},sm.decodeRelativeHeight).geometry(e=>{i.bounds=e;},Ze).success(),(e,t,i)=>e.reset(t).require(dd,e=>{i.id=e;}).require("elevation_idx",e=>{i.idx=e;}).require("extent",e=>{i.extent=e;}).require("height_relative",e=>{i.height=e;},sm.decodeRelativeHeight).geometry(e=>{i.position=e;},sm.getPoint).success()),am=new rm((e,t,i)=>e.reset(t).require(dd,e=>{i.id=e;}).optional("fixed_height",e=>{i.constantHeight=e;},sm.decodeMetricHeight).geometry(e=>{i.bounds=e;},Ze).success(),(e,t,i)=>e.reset(t).require(dd,e=>{i.id=e;}).require("elevation_idx",e=>{i.idx=e;}).require("extent",e=>{i.extent=e;}).require("height",e=>{i.height=e;},sm.decodeMetricHeight).geometry(e=>{i.position=e;},sm.getPoint).success());class sm{static getPoint(e){return be(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?am:void 0:om}static parse(e){const t=[],i=[],n=e.length,r=new nm;for(let o=0;o<n;o++){const n=e.feature(o),a=n.properties.version,s=sm.getVersionSchema(a);if(void 0===s){mt(`Unknown elevation feature version number ${a||"(unknown)"}`);continue}const l=n.properties.type;if(!l)continue;const u=Ph.types[n.type];if("Point"===u&&"curve_point"===l){const e={};s.parseVertex(r,n,e)&&t.push(e);}else if("Polygon"===u&&"curve_meta"===l){const e={};s.parseFeature(r,n,e)&&i.push(e);}}return {vertices:t,features:i}}}const lm=[ve(),ve(),ve(),ve(),ve(),ve(),ve()],um=ve(),cm=ve();function hm(e){return [e[0],e[1]]}function dm(e){return be(e[0],e[1])}class fm{constructor(e,t,i=null){this.feature=e,this.metersToTile=t,this.sampler=i,this.index=0;}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,i=t[1],n=-t[0],r=(e.extent+1)*this.metersToTile,o=this.sampler?this.sampler.pointTransform(e.position):e.position;return [new Pe(Math.trunc(o[0]+i*r),Math.trunc(o[1]+n*r)),new Pe(Math.trunc(o[0]-i*r),Math.trunc(o[1]-n*r))]}next(){this.index++;}valid(){return this.index<this.feature.vertices.length}}class pm{constructor(e,t,i,n,r,o){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this.id=e,this.heightRange={min:i,max:i},this.safeArea=t,this.constantHeight=i,null==this.constantHeight&&(null!=this.constantHeight||0!==n.length)){this.vertices=n,this.edges=r;for(let e=0;e<this.vertices.length;e++)this.vertices[e].index=void 0!==this.vertices[e].index?this.vertices[e].index:e;this.edges=this.edges.filter(e=>{return e.a<this.vertices.length&&e.b<this.vertices.length&&!((t=this.vertices[e.a].position)[0]===(i=this.vertices[e.b].position)[0]&&t[1]===i[1]);var t,i;}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const e of this.vertices)this.vertexProps.push({dir:be(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,e.height),this.heightRange.max=Math.max(this.heightRange.max,e.height);for(const e of this.edges){const t=this.vertices[e.a].position,i=this.vertices[e.b].position,n=Ae(ve(),i,t),r=Te(n),o=Ie(ve(),n,1/r);this.edgeProps.push({vec:n,dir:o,len:r});const a=this.vertexProps[e.a].dir,s=this.vertexProps[e.b].dir;Ee(a,a,o),Ee(s,s,o);}for(const e of this.vertexProps)0===e.dir[0]&&0===e.dir[1]||Me(e.dir,e.dir);this.tessellate(o);}}pointElevation(e){if(null!=this.constantHeight)return this.constantHeight;const t=this.getClosestEdge(e);if(null==t)return 0;const[i,n]=t;return dn(this.vertices[this.edges[i].a].height,this.vertices[this.edges[i].b].height,n)}computeSlopeNormal(e,t){const i=this.getClosestEdge(e);if(!i)return C(0,0,1);const n=i[0],r=this.edges[n],o=this.edgeProps[n].vec,a=C(o[0],o[1],(this.vertices[r.b].height-this.vertices[r.a].height)*t),s=C(a[1],-a[0],0);q(s,s,a);const l=D(s);return l>0?k(s,s,1/l):F(s,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,i=Number.POSITIVE_INFINITY,n=0;const[r,o,a,s,l,u,c]=lm;we(c,e.x,e.y);const h=new vf(c,null);for(let e=0;e<this.edges.length;e++){const d=this.edges[e],f=this.edgeProps[e].dir;h.dir=f;const p=this.vertices[d.a].position,_=this.vertices[d.b].position,m=h.intersectsPlane(p,this.vertexProps[d.a].dir,r),g=h.intersectsPlane(_,this.vertexProps[d.b].dir,o);if(!m||!g)continue;Ae(a,o,r),Ae(s,c,r);const y=Se(a,a),x=y>0?Se(s,a)/y:0,v=tt(x,0,1),b=Math.abs((x-v)*this.edgeProps[e].len);Ae(l,c,p),we(u,f[1],-f[0]);const w=b+Math.abs(Se(l,u));w<i&&(t=e,i=w,n=v);}return [t,n]}tessellate(e){const t=R(),i=R(),n=R(),r=R();for(let o=this.edges.length-1;o>=0;--o){const a=this.edges[o].a,s=this.edges[o].b,{position:l,height:u,extent:c}=this.vertices[a],{position:h,height:d,extent:f}=this.vertices[s],p=this.vertexProps[a].dir,_=this.vertexProps[s].dir;if(F(t,l[0]/e,l[1]/e,u),F(i,h[0]/e,h[1]/e,d),F(n,p[1],-p[0],0),k(n,n,c),F(r,_[1],-_[0],0),k(r,r,f),this.distSqLines(C(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),C(i[0]-.5*r[0],i[1]-.5*r[1],i[2]-.5*r[2]),C(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),C(i[0]+.5*r[0],i[1]+.5*r[1],i[2]+.5*r[2]))<=.0025000000000000005)continue;const m=this.vertices.length,g=Ee(ve(),l,h);this.vertices.push({position:Ie(g,g,.5),height:.5*(u+d),extent:.5*(c+f),index:.5*((void 0!==this.vertices[a].index?this.vertices[a].index:a)+(void 0!==this.vertices[s].index?this.vertices[s].index:s))});const y=Ee(ve(),p,_);this.vertexProps.push({dir:Me(y,y)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a,b:m}),this.edges.push({a:m,b:s});const x=Ae(ve(),this.vertices[m].position,l),v=Te(x),b={vec:x,dir:Ie(ve(),x,1/v),len:v};this.edgeProps.push(b),this.edgeProps.push(b);}}distSqLines(e,t,i,n){const r=L(R(),t,e),o=L(R(),n,i),a=L(R(),e,i),s=W(r,r),l=W(r,o),u=W(r,a),c=W(o,o),h=W(o,a),d=s*c-l*l;if(0===d)return j(X(r,i,n,W(a,o)/W(o,o)),e);const f=(s*h-l*u)/d;return j(X(r,e,t,(l*h-u*c)/d),X(o,i,n,f))}static serialize(e,t){const i={id:e.id,heightRange:{min:e.heightRange.min,max:e.heightRange.max},safeArea:(n=e.safeArea,{min:{x:n.min.x,y:n.min.y},max:{x:n.max.x,y:n.max.y}})};var n;return null!=e.constantHeight?(i.constantHeight=e.constantHeight,i):0===e.vertices.length?(i.vertices=[],i.vertexProps=[],i.edges=[],i.edgeProps=[],i):(i.vertices=e.vertices.map(e=>({position:hm(e.position),height:e.height,extent:e.extent,index:e.index})),i.vertexProps=e.vertexProps.map(e=>({dir:hm(e.dir)})),i.edges=e.edges.map(e=>({a:e.a,b:e.b})),i.edgeProps=e.edgeProps.map(e=>({vec:hm(e.vec),dir:hm(e.dir),len:e.len})),i)}static deserialize(e){const t=function(e){return {min:new Pe(e.min.x,e.min.y),max:new Pe(e.max.x,e.max.y)}}(e.safeArea);if(null!=e.constantHeight)return new pm(e.id,t,e.constantHeight);if(!e.vertices||0===e.vertices.length){const i=Object.create(pm.prototype);return i.id=e.id,i.constantHeight=void 0,i.heightRange={min:e.heightRange.min,max:e.heightRange.max},i.safeArea=t,i.vertices=[],i.vertexProps=[],i.edges=[],i.edgeProps=[],i}const i=Object.create(pm.prototype);return i.id=e.id,i.constantHeight=void 0,i.heightRange={min:e.heightRange.min,max:e.heightRange.max},i.safeArea=t,i.vertices=e.vertices.map(e=>({position:dm(e.position),height:e.height,extent:e.extent,index:e.index})),i.vertexProps=(e.vertexProps||[]).map(e=>({dir:dm(e.dir)})),i.edges=(e.edges||[]).map(e=>({a:e.a,b:e.b})),i.edgeProps=(e.edgeProps||[]).map(e=>({vec:dm(e.vec),dir:dm(e.dir),len:e.len})),i}}class _m{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*Sr,this.yOffset=(e.y*this.zScale-t.y)*Sr);}pointTransform(e){return be(e[0]*this.zScale+this.xOffset,e[1]*this.zScale+this.yOffset)}pointTransformInPlace(e){e[0]=e[0]*this.zScale+this.xOffset,e[1]=e[1]*this.zScale+this.yOffset;}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,i){const n=this.constantElevation(t,i);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),i))}computeBiasedHeight(e,t){return t<=0?e:e+t*it(0,t,e>=0?e:Math.abs(.5*e))}}function mm(e){if(0===e)return [0,0,0];const t=fa(e);return [t(),t(),t()]}function gm(e,t){let i=0,n=e.length-1;for(;i<=n;){const r=i+n>>1;e[r].feature.id<t?i=r+1:n=r-1;}return i<e.length&&e[i].feature.id===t?i:-1}function ym(e,t,i,n){if(!e.properties)return;const r=+e.properties[dd];if(Number.isNaN(r))return;if(t){const e=t.find(e=>e.id===r);if(e&&n)return {tileId:n,feature:e}}if(!i||0===i.length)return;const o=gm(i,r);if(!(o<0)){if(n)for(let e=o;e<i.length&&i[e].feature.id===r;e++)if(i[e].tileId.key===n.key)return i[e];return i[o]}}function xm(e,t){return e>t?1:e<t?-1:0}qa(pm,"ElevationFeature");class vm{constructor(e=xm,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t;}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t;}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t;}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t);}}splay(e){for(var t,i,n,r,o;e.parent;)(i=(t=e.parent).parent)&&i.parent?((n=i.parent).left===i?n.left=e:n.right=e,e.parent=n):(e.parent=null,this._root=e),r=e.left,o=e.right,e===t.left?(i&&(i.left===t?(t.right?(i.left=t.right,i.left.parent=i):i.left=null,t.right=i,i.parent=t):(r?(i.right=r,r.parent=i):i.right=null,e.left=i,i.parent=e)),o?(t.left=o,o.parent=t):t.left=null,e.right=t,t.parent=e):(i&&(i.right===t?(t.left?(i.right=t.left,i.right.parent=i):i.right=null,t.left=i,i.parent=t):(o?(i.left=o,o.parent=i):i.left=null,e.right=i,i.parent=e)),r?(t.right=r,r.parent=t):t.right=null,e.left=t,t.parent=e);}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent);}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,t){var i=this._root,n=null,r=this._compare;if(this._noDuplicates)for(;i;){if(n=i,0===r(i.key,e))return;i=r(i.key,e)<0?i.right:i.left;}else for(;i;)n=i,i=r(i.key,e)<0?i.right:i.left;return i={key:e,data:t,left:null,right:null,parent:n},n?r(n.key,i.key)<0?n.right=i:n.left=i:this._root=i,this.splay(i),this._size++,i}find(e){for(var t=this._root,i=this._compare;t;){var n=i(t.key,e);if(n<0)t=t.right;else {if(!(n>0))return t;t=t.left;}}return null}contains(e){for(var t=this._root,i=this._compare;t;){var n=i(e,t.key);if(0===n)return !0;t=n<0?t.left:t.right;}return !1}remove(e){var t=this.find(e);if(!t)return !1;if(this.splay(t),t.left)if(t.right){var i=this.minNode(t.right);i.parent!==t&&(this.replace(i,i.right),i.right=t.right,i.right.parent=i),this.replace(t,i),i.left=t.left,i.left.parent=i;}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return !1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t;}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var i=t.left,n=t.right,r=null;i&&(i.parent=null,r=this.maxNode(i),this.splay(r),this._root=r),n&&(i?r.right=n:this._root=n,n.parent=r),this._size--;}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key);}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,i=[],n=!1,r=0;!n;)t?(i.push(t),t=t.left):i.length>0?(e(t=i.pop(),r++),t=t.right):n=!0;return this}range(e,t,i,n){const r=[],o=this._compare;let a,s=this._root;for(;0!==r.length||s;)if(s)r.push(s),s=s.left;else {if(s=r.pop(),a=o(s.key,t),a>0)break;if(o(s.key,e)>=0&&i.call(n,s))return this;s=s.right;}return this}keys(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.key),e=e.right):n=!0;return i}values(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.data),e=e.right):n=!0;return i}at(e){for(var t=this._root,i=[],n=!1,r=0;!n;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),r===e)return t;r++,t=t.right;}else n=!0;return null}load(e=[],t=[],i=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return i&&wm(e,t,0,n-1,this._compare),this._root=bm(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,i,n,r){return new vm(i,r).load(e,t,n)}}function bm(e,t,i,n,r){const o=r-n;if(o>0){const a=n+Math.floor(o/2),s={key:t[a],data:i[a],parent:e};return s.left=bm(s,t,i,n,a),s.right=bm(s,t,i,a+1,r),s}return null}function wm(e,t,i,n,r){if(i>=n)return;const o=e[i+n>>1];let a=i-1,s=n+1;for(;;){do{a++;}while(r(e[a],o)<0);do{s--;}while(r(e[s],o)>0);if(a>=s)break;let i=e[a];e[a]=e[s],e[s]=i,i=t[a],t[a]=t[s],t[s]=i;}wm(e,t,i,s,r),wm(e,t,s+1,n,r);}const Em=11102230246251565e-32,Am=134217729,Im=(3+8*Em)*Em;function Tm(e,t,i,n,r){let o,a,s,l,u=t[0],c=n[0],h=0,d=0;c>u==c>-u?(o=u,u=t[++h]):(o=c,c=n[++d]);let f=0;if(h<e&&d<i)for(c>u==c>-u?(a=u+o,s=o-(a-u),u=t[++h]):(a=c+o,s=o-(a-c),c=n[++d]),o=a,0!==s&&(r[f++]=s);h<e&&d<i;)c>u==c>-u?(a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++h]):(a=o+c,l=a-o,s=o-(a-l)+(c-l),c=n[++d]),o=a,0!==s&&(r[f++]=s);for(;h<e;)a=o+u,l=a-o,s=o-(a-l)+(u-l),u=t[++h],o=a,0!==s&&(r[f++]=s);for(;d<i;)a=o+c,l=a-o,s=o-(a-l)+(c-l),c=n[++d],o=a,0!==s&&(r[f++]=s);return 0===o&&0!==f||(r[f++]=o),f}function Mm(e){return new Float64Array(e)}const Sm=Mm(4),zm=Mm(8),Rm=Mm(12),Pm=Mm(16),Dm=Mm(4);function Cm(e,t,i){null===t?(e.inOut=!1,e.otherInOut=!0):(e.isSubject===t.isSubject?(e.inOut=!t.inOut,e.otherInOut=t.otherInOut):(e.inOut=!t.otherInOut,e.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(e.prevInResult=!Fm(t,i)||t.isVertical()?t.prevInResult:t)),e.resultTransition=Fm(e,i)?function(e,t){let i,n=!e.inOut,r=!e.otherInOut;switch(t){case 0:i=n&&r;break;case 1:i=n||r;break;case 3:i=n!==r;break;case 2:i=e.isSubject?n&&!r:r&&!n;}return i?1:-1}(e,i):0;}function Fm(e,t){switch(e.type){case 0:switch(t){case 0:return !e.otherInOut;case 1:return e.otherInOut;case 2:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case 3:return !0}break;case 2:return 0===t||1===t;case 3:return 2===t;case 1:return !1}return !1}class Om{constructor(e,t,i,n,r){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=n??!1,this.type=r||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0;}isBelow(e){const t=this.point,i=this.otherEvent.point;return this.left?(t[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(t[1]-e[1])>0:(i[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(i[1]-e[1])>0}isAbove(e){return !this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new Om(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Lm(e,t){return e[0]===t[0]&&e[1]===t[1]}function Bm(e,t,i){const n=function(e,t,i,n,r,o){const a=(t-o)*(i-r),s=(e-r)*(n-o),l=a-s;if(0===a||0===s||a>0!=s>0)return l;const u=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,i,n,r,o,a){let s,l,u,c,h,d,f,p,_,m,g,y,x,v,b,w,E,A;const I=e-r,T=i-r,M=t-o,S=n-o;v=I*S,d=Am*I,f=d-(d-I),p=I-f,d=Am*S,_=d-(d-S),m=S-_,b=p*m-(v-f*_-p*_-f*m),w=M*T,d=Am*M,f=d-(d-M),p=M-f,d=Am*T,_=d-(d-T),m=T-_,E=p*m-(w-f*_-p*_-f*m),g=b-E,h=b-g,Sm[0]=b-(g+h)+(h-E),y=v+g,h=y-v,x=v-(y-h)+(g-h),g=x-w,h=x-g,Sm[1]=x-(g+h)+(h-w),A=y+g,h=A-y,Sm[2]=y-(A-h)+(g-h),Sm[3]=A;let z=function(e,t){let i=t[0];for(let e=1;e<4;e++)i+=t[e];return i}(0,Sm),R=22204460492503146e-32*a;if(z>=R||-z>=R)return z;if(h=e-I,s=e-(I+h)+(h-r),h=i-T,u=i-(T+h)+(h-r),h=t-M,l=t-(M+h)+(h-o),h=n-S,c=n-(S+h)+(h-o),0===s&&0===l&&0===u&&0===c)return z;if(R=11093356479670487e-47*a+Im*Math.abs(z),z+=I*c+S*s-(M*u+T*l),z>=R||-z>=R)return z;v=s*S,d=Am*s,f=d-(d-s),p=s-f,d=Am*S,_=d-(d-S),m=S-_,b=p*m-(v-f*_-p*_-f*m),w=l*T,d=Am*l,f=d-(d-l),p=l-f,d=Am*T,_=d-(d-T),m=T-_,E=p*m-(w-f*_-p*_-f*m),g=b-E,h=b-g,Dm[0]=b-(g+h)+(h-E),y=v+g,h=y-v,x=v-(y-h)+(g-h),g=x-w,h=x-g,Dm[1]=x-(g+h)+(h-w),A=y+g,h=A-y,Dm[2]=y-(A-h)+(g-h),Dm[3]=A;const P=Tm(4,Sm,4,Dm,zm);v=I*c,d=Am*I,f=d-(d-I),p=I-f,d=Am*c,_=d-(d-c),m=c-_,b=p*m-(v-f*_-p*_-f*m),w=M*u,d=Am*M,f=d-(d-M),p=M-f,d=Am*u,_=d-(d-u),m=u-_,E=p*m-(w-f*_-p*_-f*m),g=b-E,h=b-g,Dm[0]=b-(g+h)+(h-E),y=v+g,h=y-v,x=v-(y-h)+(g-h),g=x-w,h=x-g,Dm[1]=x-(g+h)+(h-w),A=y+g,h=A-y,Dm[2]=y-(A-h)+(g-h),Dm[3]=A;const D=Tm(P,zm,4,Dm,Rm);v=s*c,d=Am*s,f=d-(d-s),p=s-f,d=Am*c,_=d-(d-c),m=c-_,b=p*m-(v-f*_-p*_-f*m),w=l*u,d=Am*l,f=d-(d-l),p=l-f,d=Am*u,_=d-(d-u),m=u-_,E=p*m-(w-f*_-p*_-f*m),g=b-E,h=b-g,Dm[0]=b-(g+h)+(h-E),y=v+g,h=y-v,x=v-(y-h)+(g-h),g=x-w,h=x-g,Dm[1]=x-(g+h)+(h-w),A=y+g,h=A-y,Dm[2]=y-(A-h)+(g-h),Dm[3]=A;const C=Tm(D,Rm,4,Dm,Pm);return Pm[C-1]}(e,t,i,n,r,o,u)}(e[0],e[1],t[0],t[1],i[0],i[1]);return n>0?-1:n<0?1:0}function Nm(e,t){const i=e.point,n=t.point;return i[0]>n[0]?1:i[0]<n[0]?-1:i[1]!==n[1]?i[1]>n[1]?1:-1:function(e,t,i){return e.left!==t.left?e.left?1:-1:0!==Bm(i,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function Vm(e,t,i){const n=new Om(t,!1,e,e.isSubject),r=new Om(t,!0,e.otherEvent,e.isSubject);return Lm(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=r.contourId=e.contourId,Nm(r,e.otherEvent)>0&&(e.otherEvent.left=!0,r.left=!1),e.otherEvent.otherEvent=r,e.otherEvent=n,i.push(r),i.push(n),i}function km(e,t){return e[0]*t[1]-e[1]*t[0]}function Um(e,t){return e[0]*t[0]+e[1]*t[1]}function Gm(e,t,i){const n=function(e,t,i,n){const r=[t[0]-e[0],t[1]-e[1]],o=[n[0]-i[0],n[1]-i[1]];function a(e,t,i){return [e[0]+t*i[0],e[1]+t*i[1]]}const s=[i[0]-e[0],i[1]-e[1]];let l=km(r,o),u=l*l;const c=Um(r,r);if(u>0){const t=km(s,o)/l;if(t<0||t>1)return null;const n=km(s,r)/l;return n<0||n>1?null:0===t||1===t?[a(e,t,r)]:0===n||1===n?[a(i,n,o)]:[a(e,t,r)]}if(l=km(s,r),u=l*l,u>0)return null;const h=Um(r,s)/c,d=h+Um(r,o)/c,f=Math.min(h,d),p=Math.max(h,d);return f<=1&&p>=0?1===f?[a(e,f>0?f:0,r)]:0===p?[a(e,p<1?p:1,r)]:[a(e,f>0?f:0,r),a(e,p<1?p:1,r)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),r=n?n.length:0;if(0===r||1===r&&(Lm(e.point,t.point)||Lm(e.otherEvent.point,t.otherEvent.point))||2===r&&e.isSubject===t.isSubject)return 0;if(1===r)return !Lm(e.point,n[0])&&!Lm(e.otherEvent.point,n[0])&&Vm(e,n[0],i),!Lm(t.point,n[0])&&!Lm(t.otherEvent.point,n[0])&&Vm(t,n[0],i),1;const o=[];let a=!1,s=!1;return Lm(e.point,t.point)?a=!0:1===Nm(e,t)?o.push(t,e):o.push(e,t),Lm(e.otherEvent.point,t.otherEvent.point)?s=!0:1===Nm(e.otherEvent,t.otherEvent)?o.push(t.otherEvent,e.otherEvent):o.push(e.otherEvent,t.otherEvent),a&&s||a?(t.type=1,e.type=t.inOut===e.inOut?2:3,a&&!s&&Vm(o[1].otherEvent,o[0].point,i),2):s?(Vm(o[0],o[1].point,i),3):o[0]!==o[3].otherEvent?(Vm(o[0],o[1].point,i),Vm(o[1],o[2].point,i),3):(Vm(o[0],o[1].point,i),Vm(o[3].otherEvent,o[2].point,i),3)}function jm(e,t){if(e===t)return 0;if(0!==Bm(e.point,e.otherEvent.point,t.point)||0!==Bm(e.point,e.otherEvent.point,t.otherEvent.point))return Lm(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]<t.point[1]?-1:1:1===Nm(e,t)?t.isAbove(e.point)?-1:1:e.isBelow(t.point)?-1:1;if(e.isSubject!==t.isSubject)return e.isSubject?-1:1;{let i=e.point,n=t.point;if(i[0]===n[0]&&i[1]===n[1])return i=e.otherEvent.point,n=t.otherEvent.point,i[0]===n[0]&&i[1]===n[1]?0:(e.contourId??0)>(t.contourId??0)?1:-1}return 1===Nm(e,t)?1:-1}class Hm{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null;}isExterior(){return null==this.holeOf}}function $m(e,t,i,n){let r,o=e+1,a=t[e].point;const s=t.length;for(o<s&&(r=t[o].point);o<s&&r[0]===a[0]&&r[1]===a[1];){if(!i[o])return o;o++,o<s&&(r=t[o].point);}for(o=e-1;i[o]&&o>n;)o--;return o}function Zm(e,t,i){const n=new Hm;if(null!=e.prevInResult){const r=e.prevInResult,o=r.outputContourId;if(r.resultTransition>0){const e=t[o];if(null!=e.holeOf){const r=e.holeOf;t[r].holeIds.push(i),n.holeOf=r,n.depth=t[o].depth;}else t[o].holeIds.push(i),n.holeOf=o,n.depth=t[o].depth+1;}else n.holeOf=null,n.depth=t[o].depth;}else n.holeOf=null,n.depth=0;return n}const Wm=Math.max,qm=Math.min;let Xm=0;function Ym(e,t,i,n,r,o){let a,s,l,u,c,h;for(a=0,s=e.length-1;a<s;a++){if(l=e[a],u=e[a+1],c=new Om(l,!1,void 0,t),h=new Om(u,!1,c,t),c.otherEvent=h,l[0]===u[0]&&l[1]===u[1])continue;c.contourId=h.contourId=i,o||(c.isExteriorRing=!1,h.isExteriorRing=!1),Nm(c,h)>0?h.left=!0:c.left=!0;const s=l[0],d=l[1];r[0]=qm(r[0],s),r[1]=qm(r[1],d),r[2]=Wm(r[2],s),r[3]=Wm(r[3],d),n.push(c),n.push(h);}}const Jm=[];function Km(e,t,i){let n=e,r=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(r=[t]);let o=function(e,t,i){let n=null;return e.length*t.length===0&&(0===i?n=Jm:2===i?n=e:(1===i||3===i)&&(n=0===e.length?t:e)),n}(n,r,i);if(o)return o===Jm?null:o;const a=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],l=function(e,t,i,n,r){const o=new Mr(void 0,Nm);let a,s,l,u,c,h;for(l=0,u=e.length;l<u;l++)for(a=e[l],c=0,h=a.length;c<h;c++)s=0===c,s&&Xm++,Ym(a[c],!0,Xm,o,i,s);for(l=0,u=t.length;l<u;l++)for(a=t[l],c=0,h=a.length;c<h;c++)s=0===c,2===r&&(s=!1),s&&Xm++,Ym(a[c],!1,Xm,o,n,s);return o}(n,r,a,s,i);if(o=function(e,t,i,n,r){let o=null;return (i[0]>n[2]||n[0]>i[2]||i[1]>n[3]||n[1]>i[3])&&(0===r?o=Jm:2===r?o=e:(1===r||3===r)&&(o=e.concat(t))),o}(n,r,a,s,i),o)return o===Jm?null:o;const u=function(e,t,i,n,r,o){const a=new vm(jm),s=[],l=Math.min(n[2],r[2]);let u,c,h;for(;0!==e.length;){let t=e.pop();if(s.push(t),0===o&&t.point[0]>l||2===o&&t.point[0]>n[2])break;if(t.left){c=u=a.insert(t),h=a.minNode(),u=u!==h?a.prev(u):null,c=a.next(c);const i=u?u.key:null;let n;if(Cm(t,i,o),c&&2===Gm(t,c.key,e)&&(Cm(t,i,o),Cm(c.key,t,o)),u&&2===Gm(u.key,t,e)){let e=u;e=e!==h?a.prev(e):null,n=e?e.key:null,Cm(i,n,o),Cm(t,i,o);}}else t=t.otherEvent,c=u=a.find(t),u&&c&&(u=u!==h?a.prev(u):null,c=a.next(c),a.remove(t),c&&u&&Gm(u.key,c.key,e));}return s}(l,0,0,a,s,i),c=function(e){let t,i;const n=function(e){let t,i,n,r,o;const a=[];for(i=0,n=e.length;i<n;i++)t=e[i],(t.left&&t.inResult||!t.left&&t.otherEvent.inResult)&&a.push(t);let s=!1;for(;!s;)for(s=!0,i=0,n=a.length;i<n;i++)i+1<n&&1===Nm(a[i],a[i+1])&&(r=a[i],a[i]=a[i+1],a[i+1]=r,s=!1);for(i=0,n=a.length;i<n;i++)t=a[i],t.otherPos=i;for(i=0,n=a.length;i<n;i++)t=a[i],t.left||(o=t.otherPos,t.otherPos=t.otherEvent.otherPos,t.otherEvent.otherPos=o);return a}(e),r={},o=[];for(t=0,i=n.length;t<i;t++){if(r[t])continue;const e=o.length,i=Zm(n[t],o,e),a=t=>{r[t]=!0,t<n.length&&n[t]&&(n[t].outputContourId=e);};let s=t,l=t;for(i.points.push(n[t].point);a(s),s=n[s].otherPos,a(s),i.points.push(n[s].point),s=$m(s,n,r,l),!(s==l||s>=n.length)&&n[s];);o.push(i);}return o}(u),h=[];for(let e=0;e<c.length;e++){let t=c[e];if(t.isExterior()){let e=[t.points];for(let i=0;i<t.holeIds.length;i++)e.push(c[t.holeIds[i]].points);h.push(e);}}return h}function Qm(e,t){const i=Km(tg(e),tg([t]),0);return null==i?[]:rg(i)}function eg(e,t,i=0){const n=65536;let r=tg(e,n);const o=[];for(;t.valid();t.next()){const[e,r]=t.get();let a=e.x*n,s=e.y*n,l=r.x*n,u=r.y*n;const c=l-a,h=u-s,d=Math.hypot(c,h);if(0===d)continue;a-=c*i,s-=h*i,l+=c*i,u+=h*i;const f=Math.trunc(h/d*3),p=-Math.trunc(c/d*3);o.push([[[a,s],[l,u],[l+f,u+p],[a+f,s+p],[a,s]]]);}return o.length>0&&(r=Km(r,o,2)),rg(r,1/n,.001)}function tg(e,t=1){return [e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function ig(e,t){const i=Math.floor(e)+.5;return Math.abs(e-i)<=t?Math.round(i):Math.round(e)}class ng{constructor(e){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=e;}canonicalize(e,t){const i=this.tolerance,n=Math.floor(e/i),r=Math.floor(t/i);for(let o=-1;o<=1;o++){const a=this.buckets.get(n+o);if(a)for(let o=-1;o<=1;o++){const s=a.get(r+o);if(s)for(const o of s)if(Math.abs(this.xs[o]-e)<=i&&Math.abs(this.ys[o]-t)<=i){const i=this.ixs[o],a=this.iys[o];return this.xs[o]===e&&this.ys[o]===t||this.store(e,t,i,a,n,r),[i,a]}}}const o=ig(e,i),a=ig(t,i);return this.store(e,t,o,a,n,r),[o,a]}store(e,t,i,n,r,o){const a=this.xs.length;this.xs.push(e),this.ys.push(t),this.ixs.push(i),this.iys.push(n);let s=this.buckets.get(r);s||(s=new Map,this.buckets.set(r,s));let l=s.get(o);l||(l=[],s.set(o,l)),l.push(a);}}function rg(e,t=1,i){const n=null!=i?new ng(i):null;return e.map(e=>e.map((e,i)=>{const r=e.map(e=>{const i=e[0]*t,r=e[1]*t;if(n){const[e,t]=n.canonicalize(i,r);return new Pe(e,t)}return new Pe(Math.round(i),Math.round(r))});return i>0&&r.reverse(),r}))}class og{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new Uc;}empty(){return 0===this.frcCoverage.size}}function ag(e,t,i){if(0===e.frcCoverage.size||0===e.featureTriSegments.length)return;const n=i.get(),r=t.uint16,o=[];e.featureTriSegments.sort((e,t)=>e.segIdx!==t.segIdx?e.segIdx-t.segIdx:null===e.frc&&null===t.frc?0:null===e.frc?-1:null===t.frc?1:t.frc-e.frc);const a=new Map;let s=0,l=e.featureTriSegments[0].frc,u={vertexOffset:n[s].vertexOffset,primitiveOffset:0,vertexLength:n[s].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0};const c=()=>{u.primitiveLength>0&&(a.has(l)||a.set(l,[]),a.get(l).push({...u}));};for(const t of e.featureTriSegments){t.segIdx!==s&&(c(),s=t.segIdx,l=t.frc,u={vertexOffset:n[s].vertexOffset,primitiveOffset:o.length/3,vertexLength:n[s].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),t.frc!==l&&(c(),l=t.frc,u={...u,primitiveOffset:o.length/3,primitiveLength:0});for(let e=t.start;e<t.end;e++)o.push(r[e]);u.primitiveLength+=(t.end-t.start)/3;}c();for(let e=0;e<o.length;e++)r[e]=o[e];for(const[t,i]of a)null!==t?e.frcPerLevel.set(t,new Uc(i)):e.frcNonRoadSegments=new Uc(i);e.featureTriSegments=[];}qa(og,"FrcSegmentData");const sg={motorway:0,motorway_link:0,trunk:1,trunk_link:1,primary:2,primary_link:2,secondary:3,secondary_link:3,tertiary:4,tertiary_link:4,unclassified:5,unclassified_link:5,street:6,street_limited:6,residential:6,service:7,living_street:7,pedestrian:8,track:8,path:8,footway:8,cycleway:8,sidewalk:8,crossing:8};function lg(e){for(const t of ["class","incident_class"]){const i=e[t];if("string"!=typeof i)continue;const n=sg[i];if(void 0!==n)return n}return null}function ug(e,t,i){for(const n of e)if(n.startsWith("(")){const e=n.indexOf(")");if(-1===e)continue;if(n.slice(1,e)===t&&n.slice(e+1)===i)return !0}else if(n===i)return !0;return !1}class cg{constructor(e,t,i){this.elevationMode=t,t&&(this.elevationBufferData=new Q_(e.layers,e.zoom,e.lut)),i&&(this.frcData=new og);}isEmpty(){const e=!this.elevationBufferData||this.elevationBufferData.isEmpty(),t=!this.frcData||this.frcData.empty();return e&&t}needsUpload(){return !!this.elevationBufferData&&this.elevationBufferData.needsUpload()}trackFeatureFrc(e){if(!this.frcData)return null;const t=lg(e||{});return null!==t&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,i,n){if(!this.frcData||i<=t)return;const r=e.bufferData.triangleSegments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*i,segIdx:r.length>0?r.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&ag(this.frcData,e.bufferData.indexArray,e.bufferData.triangleSegments);}handleFeature(e,t,i,n,r,o){const a=new Array;if(!this.elevationMode)return !1;const s=ym(e,r,void 0,n);if(!s)return !1;{const e=this.clipPolygonsToTile(t,1);e.length>0&&a.push({polygons:e,elevationFeature:s.feature,elevationTileID:s.tileId});}const l={guardRailEnabled:o.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},n),featureIndex:i};for(const t of a)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new im(t.elevationTileID,o.layers,o.zoom,o.lut));const i=t.elevationFeature.isTunnel();let n=0;Object.hasOwn(e.properties,fd)&&(n=+e.properties[fd]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,i,t.elevationFeature,n);}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const r=new _m(n,t.elevationTileID);this.addElevatedGeometry(o,t.polygons,r,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,i,l);}return !0}populatePaintArrays(e,t,i,n,r,o,a){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(e,t,i,n,r,o,a);}update(e,t,i,n,r,o,a,s){this.elevationBufferData&&this.elevationBufferData.update(e,t,i,n,r,o,a,s),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,n,r,o,a,s);}updateExpressions(e){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e));}upload(e){this.elevationBufferData&&this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e);}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy();}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,i,n,r,o){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,n,r,o));}addElevatedGeometry(e,t,i,n,r,o,a){const s={elevation:n,elevationSampler:i,bias:r,index:o,featureInfo:a},[l,u]=e.addGeometry(t,this.elevationBufferData,s,this.elevatedStructures);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:l,max:u}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,l),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,u));}prepareElevatedPolygons(e,t,i){const n=1/Au(i),r=[];for(const i of e){const e=eg(i,new fm(t,n),.1);r.push(...e);}return r}clipPolygonsToTile(e,t){const i=-t,n=-t,r=Sr+t,o=Sr+t;let a=0;const s=[],l=[];for(;a<e.length;a++){const t=e[a],u=Ze(t);(u.min.x>=i&&u.max.x<=r&&u.min.y>=n&&u.max.y<=o?s:l).push(t);}if(s.length===e.length)return e;const u=[new Pe(i,n),new Pe(r,n),new Pe(r,o),new Pe(i,o),new Pe(i,n)],c=s;for(const e of l)c.push(...Qm(e,u));return c}}function hg(e,t){return e.nextPoint.sub(t.at(-2)).unit()}function dg(e,t){return t[1].sub(e.prevPoint).unit()}qa(cg,"FillHDExtension"),qa(im,"ElevatedStructures");class fg{constructor(e,t){this.elevationEnabled=e,this.hasDeferredElevationFeatures=!1,t&&(this.frcData=new og);}isEmpty(){const e=!this.elevationEnabled||void 0===this.heightRange,t=!this.frcData||this.frcData.empty();return e&&t}trackFeatureFrc(e){if(!this.frcData)return null;const t=lg(e||{});return null!==t&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,i,n){if(!this.frcData||i<=t)return;const r=e.segments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*i,segIdx:r.length>0?r.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&ag(this.frcData,e.indexArray,e.segments);}handleFeature(e,t,i,n,r,o,a,s,l,u,c){if(!this.elevationEnabled)return !1;if(!c.terrainEnabled){const h=ym(e,n,r?r.registry:void 0,i),d=null!=e.properties&&Object.hasOwn(e.properties,dd)&&!Number.isNaN(+e.properties[dd]);if(!h&&d&&o&&(!r||!r.allProvidersReady))return this.hasDeferredElevationFeatures=!0,!0;if(h){let n=h.feature,o=h.tileId;if(!h.tileId.equals(i)){const t=this.mergedFeatureCache?this.mergedFeatureCache.get(n.id):void 0;if(t)n=t,o=i;else {const t=function(e,t,i){if(!e.properties||!t||0===t.length)return [];const n=+e.properties[dd];if(Number.isNaN(n))return [];const r=gm(t,n);if(r<0)return [];const o=[];for(let e=r;e<t.length&&t[e].feature.id===n;e++){const n=t[e];(n.tileId.isChildOf(i)||i.isChildOf(n.tileId)||null!=n.feature.constantHeight)&&o.push(n);}return o}(e,r?r.registry:void 0,i);t.length>1&&(n=function(e,t){const i=t.slice().sort((e,t)=>t.tileId.z-e.tileId.z),n=new Pe(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new Pe(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),o=[];for(const t of i){const i=new _m(t.tileId,e);for(const e of t.feature.vertices)o.push({position:i.pointTransform(e.position),height:e.height,extent:e.extent,index:e.index});const a=t.feature.safeArea;um[0]=a.min.x,um[1]=a.min.y,cm[0]=a.max.x,cm[1]=a.max.y,i.pointTransformInPlace(um),i.pointTransformInPlace(cm),n.x=Math.min(n.x,um[0],cm[0]),n.y=Math.min(n.y,um[1],cm[1]),r.x=Math.max(r.x,um[0],cm[0]),r.y=Math.max(r.y,um[1],cm[1]);}const a={min:n,max:r};if(null!=i[0].feature.constantHeight)return new pm(i[0].feature.id,a,i[0].feature.constantHeight);o.sort((e,t)=>e.index-t.index);const s=[];for(const e of o)0!==s.length&&s.at(-1).index===e.index||s.push(e);const l=[];for(let e=1;e<s.length;e++)s[e].index-s[e-1].index<=1&&l.push({a:e-1,b:e});const u=1/Au(e);return new pm(i[0].feature.id,a,void 0,s,l,u)}(i,t),o=i,this.mergedFeatureCache||(this.mergedFeatureCache=new Map),this.mergedFeatureCache.set(n.id,n));}}const d=id(t,-1,-1,8193,8193),f=this.prepareElevatedLines(d,n,o,i);for(const t of f){const r=c.layoutVertexArray.length;c.addLine(t,e,i,a,s,l,u);const h=new _m(i,o),d=c.showElevationIdDebug?mm(n.id):null;for(let e=r;e<c.layoutVertexArray.length;e++){const t=new Pe(c.layoutVertexArray.int16[6*e]>>1,c.layoutVertexArray.int16[6*e+1]>>1),i=h.pointElevation(t,n,.05);this.updateHeightRange(i),e<c.zOffsetVertexArray.length?c.zOffsetVertexArray.float32[4*e]=i:c.zOffsetVertexArray.emplaceBack(i,0,0,0),d?e<c.elevationIdColVertexArray.length?(c.elevationIdColVertexArray.float32[3*e]=d[0],c.elevationIdColVertexArray.float32[3*e+1]=d[1],c.elevationIdColVertexArray.float32[3*e+2]=d[2]):c.elevationIdColVertexArray.emplaceBack(d[0],d[1],d[2]):c.showElevationIdDebug&&(e<c.elevationIdColVertexArray.length?(c.elevationIdColVertexArray.float32[3*e]=0,c.elevationIdColVertexArray.float32[3*e+1]=0,c.elevationIdColVertexArray.float32[3*e+2]=0):c.elevationIdColVertexArray.emplaceBack(0,0,0));}}return !0}if(d&&o&&r&&r.allProvidersReady&&r.hasCoveringTile)return !0}const h=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics,d=c.layoutVertexArray.length,f=[],p=id(t,-1,-1,8193,8193,f);for(let t=0;t<p.length;t++){const n=p[t],r=f[t],o={progress:{min:r.progress.min,max:r.progress.max},nextDir:hg(r,n),prevDir:dg(r,n)};c.addLine(n,e,i,a,s,l,u,o,h&&r.parentIndex>0?r.parentIndex:null);}return c.fillNonElevatedRoadSegment(d),!0}prepareElevatedLines(e,t,i,n){if(null!=t.constantHeight)return e;const r=[],o=1/Au(n),a=i.equals(n)?null:new _m(i,n);for(const i of e)nd(i,new fm(t,o,a),0,r);return r}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e};}endPopulate(){this.mergedFeatureCache=void 0;}}qa(fg,"LineHDExtension");class pg{constructor(){this.elevatedLayoutVertexArray=new Hu,this.hasElevation=!1;}beginFeature(e,t,i){const n=ym(e,t,void 0,i);this.currentFeatureElevation=n?n.feature:void 0;}writeVertexQuad(e,t){const i=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new Pe(e,t)):0;this.hasElevation=this.hasElevation||0!==i;for(let e=0;e<4;e++)this.elevatedLayoutVertexArray.emplaceBack(i);}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0);}upload(e){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,vd.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy();}}qa(pg,"CircleHDExtension");const _g=(e,t,i,n)=>{for(let r=0;r<t;r++)e.emplaceBack(i[0],i[1],i[2],n[0],n[1],n[2]);};class mg{constructor(){this.elevationFeatures=[],this.elevationFeatureTileIds=[],this.elevationFeatureIdToIndex=new Map,this.elevationStateComplete=!1,this.hasDeferredElevationFeatures=!1,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1;}configureCrossSource(e,t,i,n){this.consumerCanonical=e,this.elevationParams=t,this.crossSourceElevationEnabled=i,this.terrainEnabled=n;}addElevationFeatures(e,t){for(const i of e)this.elevationFeatureIdToIndex.set(i.id,this.elevationFeatures.length),this.elevationFeatures.push(i),this.elevationFeatureTileIds.push(t);}resolveRoadElevation(e,t){const i=this.elevationFeatureIdToIndex.get(t);if(void 0!==i)return i;if(this.terrainEnabled||!this.crossSourceElevationEnabled)return 65535;const n=ym(e,void 0,this.elevationParams?this.elevationParams.registry:void 0,this.consumerCanonical);if(n){const e=this.elevationFeatures.length;return this.elevationFeatureIdToIndex.set(t,e),this.elevationFeatures.push(n.feature),this.elevationFeatureTileIds.push(n.tileId),e}return this.elevationParams&&this.elevationParams.allProvidersReady?65535:(this.hasDeferredElevationFeatures=!0,"defer")}getElevationFeatureSampler(e,t){if(t.equals(e))return new _m(e,t);this.elevationFeatureSamplerCache||(this.elevationFeatureSamplerCache=new Map);let i=this.elevationFeatureSamplerCache.get(t.key);return i||(i=new _m(e,t),this.elevationFeatureSamplerCache.set(t.key,i)),i}isCrossTileRoadElevation(e,t){if(65535===e||e>=this.elevationFeatures.length)return !1;const i=this.elevationFeatureTileIds[e];return null!=i&&!i.equals(t)}getRoadFeatureHeightAtAnchor(e,t,i){if(65535===e||e>=this.elevationFeatures.length)return null;const n=this.elevationFeatures[e],r=this.elevationFeatureTileIds[e];return r.equals(i)?n.pointElevation(t):this.getElevationFeatureSampler(i,r).pointElevation(new Pe(t.x,t.y),n,0)}sampleRoadFeatureHeight(e,t,i){const n=this.getRoadFeatureHeightAtAnchor(e,t,i);return null===n?void 0:n}clearWorkerState(){this.consumerCanonical=void 0,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1,this.elevationFeatureIdToIndex.clear();}updateRoadElevation(e,t){if(this.elevationStateComplete)return;this.elevationStateComplete=!0,e.hasAnyZOffset=!1;let i=!1;const n=Au(t),r=1/n;let o=!1,a=!1;for(let s=0;s<e.symbolInstances.length;s++){const l=e.symbolInstances.get(s),u=C(1,0,0),c=C(0,1,0),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:d,numIconVertices:f,numVerticalIconVertices:p}=l,_=h>0||d>0,m=f>0,g=l.elevationFeatureIndex,y=g<this.elevationFeatures.length?this.elevationFeatures[g]:void 0;if(y){const s=new Pe(l.tileAnchorX,l.tileAnchorY),h=this.sampleRoadFeatureHeight(g,s,t),d=void 0!==h?.075+h:.075;l.zOffset!==d&&(i=!0,l.zOffset=d),0!==d&&(e.hasAnyZOffset=!0);const f=y.computeSlopeNormal(s,r),p=xe(ue(),C(0,0,1),f);K(u,u,p),K(c,c,p),u[2]*=n,c[2]*=n,1===u[0]&&0===u[1]&&0===u[2]&&0===c[0]&&1===c[1]&&0===c[2]||(o=o||_,a=a||m);}if(_&&(_g(e.text.orientationVertexArray,h,u,c),_g(e.text.orientationVertexArray,d,u,c)),m){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=l;t>=0&&_g(e.icon.orientationVertexArray,f,u,c),i>=0&&_g(e.icon.orientationVertexArray,p,u,c);}}o||(e.text.orientationVertexArray=void 0),a||(e.icon.orientationVertexArray=void 0),i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}getRoadFeatureHeightForPlacedSymbol(e,t,i,n,r){const o=e.symbolInstances.get(t.symbolInstanceIndices[i]);return this.getRoadFeatureHeightAtAnchor(o.elevationFeatureIndex,n,r)}getElevationFeatureForPlacedSymbol(e,t,i){const n=e.symbolInstances.get(t.symbolInstanceIndices[i]).elevationFeatureIndex;if(n<this.elevationFeatures.length)return this.elevationFeatures[n]}makeRoadSymbolElevationParams(e,t,i,n,r,o,a,s,l){const u=this.getElevationFeatureForPlacedSymbol(e,t,i),c=void 0!==u?u:null,h=e.symbolInstances.get(t.symbolInstanceIndices[i]);return this.isCrossTileRoadElevation(h.elevationFeatureIndex,n.canonical)?{getElevation:r=>{const o=this.getRoadFeatureHeightForPlacedSymbol(e,t,i,r,n.canonical);return function(e,t,i,n,r,o){const a=n.upVector(t,i.x,i.y);return k(a,a,e*n.upVectorScale(t,r,o).metersToTile),[a[0],a[1],a[2]]}(null!==o?o:0,n.canonical,r,a,s,l)},elevation:o,elevationFeature:null}:{getElevation:r,elevation:o,elevationFeature:c}}}qa(mg,"SymbolHDExtension",{omit:["consumerCanonical","elevationParams","crossSourceElevationEnabled","terrainEnabled","hasDeferredElevationFeatures","elevationFeatureIdToIndex"]});let gg=null,yg=null,xg=null,vg=null;const bg=5120,wg=5121,Eg=5122,Ag=5123,Ig=5125,Tg=5126,Mg={[bg]:Int8Array,[wg]:Uint8Array,[Eg]:Int16Array,[Ag]:Uint16Array,[Ig]:Uint32Array,[Tg]:Float32Array},Sg={[bg]:"DT_INT8",[wg]:"DT_UINT8",[Eg]:"DT_INT16",[Ag]:"DT_UINT16",[Ig]:"DT_UINT32",[Tg]:"DT_FLOAT32"},zg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Rg(e,t,i){const n=i.json.bufferViews.length,r=i.buffers.length;t.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:e.byteLength},i.buffers[r]=e;}const Pg="KHR_draco_mesh_compression";function Dg(e,t){const i=e.extensions&&e.extensions[Pg];if(!i)return;const n=new gg.Decoder,r=Vg(t,i.bufferView),o=new gg.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],s=Mg[a.componentType],l=a.count*s.BYTES_PER_ELEMENT,u=gg._malloc(l);s===Uint16Array?n.GetTrianglesUInt16Array(o,l,u):n.GetTrianglesUInt32Array(o,l,u),Rg(gg.memory.buffer.slice(u,u+l),a,t),gg._free(u);for(const r of Object.keys(i.attributes)){const a=n.GetAttributeByUniqueId(o,i.attributes[r]),s=t.json.accessors[e.attributes[r]],l=Sg[s.componentType],u=s.count*zg[s.type]*Mg[s.componentType].BYTES_PER_ELEMENT,c=gg._malloc(u);n.GetAttributeDataArrayForAllPoints(o,a,gg[l],u,c),Rg(gg.memory.buffer.slice(c,c+u),s,t),gg._free(c);}n.destroy(),o.destroy(),delete e.extensions[Pg];}const Cg="EXT_meshopt_compression";function Fg(e,t){if(!e.extensions||!e.extensions[Cg])return;const i=e.extensions[Cg],n=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);xg.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=r.buffer,delete e.extensions[Cg];}const Og=1179937895,Lg=new TextDecoder("utf8");function Bg(e,t){return new URL(e,t).href}async function Ng(e,t,i,n,r){const o=await fetch(Bg(e.uri,n),{signal:r}),a=await o.arrayBuffer();t.buffers[i]=a;}function Vg(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}async function kg(e,t,i,n,r){if(e.uri){const o=Bg(e.uri,n),a=await fetch(o,{signal:r}),s=await a.blob(),l=await createImageBitmap(s);t.images[i]=l;}else if(void 0!==e.bufferView){const n=Vg(t,e.bufferView),r=new Blob([n],{type:e.mimeType}),o=await createImageBitmap(r);t.images[i]=o;}}async function Ug(e,t=0,i,n){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Og){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,a=i[n++]>>2;if(n++,r.json=JSON.parse(Lg.decode(i.subarray(n,n+a))),n+=a,n<o){const o=i[n++];n++;const a=t+(n<<2);r.buffers[0]=e.slice(a,a+o);}}else r.json=JSON.parse(Lg.decode(new Uint8Array(e,t)));const{buffers:o,images:a,meshes:s,extensionsUsed:l,bufferViews:u}=r.json;if(o){const e=[];for(let t=0;t<o.length;t++){const a=o[t];a.uri?e.push(Ng(a,r,t,i,n)):r.buffers[t]||(r.buffers[t]=null);}await Promise.all(e);}n&&n.throwIfAborted();const c=[],h=l&&l.includes(Pg),d=l&&l.includes(Cg);if(h&&c.push(function(){if(!gg)return null!=yg||(yg=function(e){let t,i=null;function n(){t=new Uint8Array(i.buffer);}function r(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(e,{a:{a:r,d:function(e,i,n){return t.copyWithin(e,i,i+n)},c:function(e){const r=t.length,o=Math.max(e>>>0,Math.ceil(1.2*r)),a=Math.ceil((o-r)/65536);try{return i.grow(a),n(),!0}catch(e){return !1}},b:r}}).then(e=>{const{Rb:r,Qb:o,P:a,T:s,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:f,eb:p,jb:_,f:m,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:E}=e.instance.exports;i=g;const A=(()=>{let e=0,i=0,n=0,a=0;return s=>{n&&(r(a),r(e),i+=n,n=e=0),e||(i+=128,e=o(i));const l=s.length+7&-8;let u=e;l>=i&&(n=l,u=a=o(l));for(let e=0;e<s.length;e++)t[u+e]=s[e];return u}})();return n(),m(),{memory:g,_free:r,_malloc:o,Mesh:class{constructor(){this.ptr=a();}destroy(){s(this.ptr);}},Decoder:class{constructor(){this.ptr=u();}destroy(){_(this.ptr);}DecodeArrayToMesh(e,t,i){const n=A(e),r=c(this.ptr,n,t,i.ptr);return !!l(r)}GetAttributeByUniqueId(e,t){return {ptr:h(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,i){d(this.ptr,e.ptr,t,i);}GetTrianglesUInt32Array(e,t,i){f(this.ptr,e.ptr,t,i);}GetAttributeDataArrayForAllPoints(e,t,i,n,r){p(this.ptr,e.ptr,t.ptr,i,n,r);}},DT_INT8:y(),DT_UINT8:x(),DT_INT16:v(),DT_UINT16:b(),DT_UINT32:w(),DT_FLOAT32:E()}})}(fetch(Gt())).then(e=>{gg=e,yg=null;})),yg}()),d&&c.push(function(){var e;if(!xg)return null!=vg||(vg=(e=fetch(jt()),WebAssembly.instantiateStreaming(e,{}).then(e=>{const{sbrk:t,memory:i,meshopt_decodeVertexBuffer:n,meshopt_decodeIndexBuffer:r,meshopt_decodeIndexSequence:o,meshopt_decodeFilterOct:a,meshopt_decodeFilterQuat:s,meshopt_decodeFilterExp:l}=e.instance.exports,u={ATTRIBUTES:n,TRIANGLES:r,INDICES:o},c={OCTAHEDRAL:a,QUATERNION:s,EXPONENTIAL:l};return e.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(e,n,r,o,a,s){const l=n+3&-4,h=t(l*r),d=t(o.length),f=new Uint8Array(i.buffer);f.set(o,d);const p=u[a](h,n,r,d,o.length);if(0===p&&c[s]&&c[s](h,l,r),e.set(f.subarray(h,h+n*r)),t(h-t(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}}})).then(e=>{xg=e,vg=null;})),vg}()),a)for(let e=0;e<a.length;e++)c.push(kg(a[e],r,e,i,n));if(c.length&&await Promise.all(c),n&&n.throwIfAborted(),h&&s)for(const{primitives:e}of s)for(const t of e)Dg(t,r);if(d&&s&&u)for(const e of u)Fg(e,r);return r}async function Gg(e,t){const{data:i}=await _i({url:e},t);return Ug(i,0,e,t)}class jg{constructor(e,t,i,n){if(this.triangleCount=t.length/3,this.min=new Pe(0,0),this.max=new Pe(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[r,o]=[e[0].clone(),e[0].clone()];for(let t=1;t<e.length;++t){const i=e[t];r.x=Math.min(r.x,i.x),r.y=Math.min(r.y,i.y),o.x=Math.max(o.x,i.x),o.y=Math.max(o.y,i.y);}if(n){const e=Math.ceil(Math.max(o.x-r.x,o.y-r.y)/n);i=Math.max(i,e);}if(0===i)return;this.min=r,this.max=o;const a=this.max.sub(this.min);a.x=Math.max(a.x,1),a.y=Math.max(a.y,1);const s=Math.max(a.x,a.y)/i;this.cellsX=Math.max(1,Math.ceil(a.x/s)),this.cellsY=Math.max(1,Math.ceil(a.y/s)),this.xScale=1/s,this.yScale=1/s;const l=[];for(let i=0;i<this.triangleCount;i++){const n=e[t[3*i+0]].sub(this.min),r=e[t[3*i+1]].sub(this.min),o=e[t[3*i+2]].sub(this.min),a=Hg(Math.floor(Math.min(n.x,r.x,o.x)),this.xScale,this.cellsX),u=Hg(Math.floor(Math.max(n.x,r.x,o.x)),this.xScale,this.cellsX),c=Hg(Math.floor(Math.min(n.y,r.y,o.y)),this.yScale,this.cellsY),h=Hg(Math.floor(Math.max(n.y,r.y,o.y)),this.yScale,this.cellsY),d=new Pe(0,0),f=new Pe(0,0),p=new Pe(0,0),_=new Pe(0,0);for(let e=c;e<=h;++e){d.y=f.y=e*s,p.y=_.y=(e+1)*s;for(let t=a;t<=u;++t)d.x=p.x=t*s,f.x=_.x=(t+1)*s,(Jh(n,r,o,d,f,_)||Jh(n,r,o,d,_,p))&&l.push({cellIdx:e*this.cellsX+t,triIdx:i});}}if(0===l.length)return;l.sort((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let u=0;for(;u<l.length;){const e=l[u].cellIdx,t={start:this.payload.length,len:0};for(;u<l.length&&l[u].cellIdx===e;)++t.len,this.payload.push(l[u++].triIdx);this.cells[e]=t;}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0);}queryPoint(e,t){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Hg(e.x-this.min.x,this.xScale,this.cellsX),n=Hg(e.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let e=0;e<r.len;e++){const i=this.payload[r.start+e],n=Math.floor(i/8),o=1<<i%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,t.push(i),t.length===this.triangleCount))return}}}query(e,t,i){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Hg(e.x-this.min.x,this.xScale,this.cellsX),r=Hg(t.x-this.min.x,this.xScale,this.cellsX),o=Hg(e.y-this.min.y,this.yScale,this.cellsY),a=Hg(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=a;e++)for(let t=n;t<=r;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;e<n.len;e++){const t=this.payload[n.start+e],r=Math.floor(t/8),o=1<<t%8;if(!(this.lookup[r]&o)&&(this.lookup[r]|=o,i.push(t),i.length===this.triangleCount))return}}}}function Hg(e,t,i){return Math.max(0,Math.min(i-1,Math.floor(e*t)))}qa(jg,"TriangleGridIndex");const $g=Vu([{name:"a_pos_3f",components:3,type:"Float32"}]),Zg=Vu([{name:"a_color_3f",components:3,type:"Float32"}]),Wg=Vu([{name:"a_color_4f",components:4,type:"Float32"}]),qg=Vu([{name:"a_uv_2f",components:2,type:"Float32"}]),Xg=Vu([{name:"a_normal_3f",components:3,type:"Float32"}]),Yg=Vu([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Jg=Vu([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Kg(e,t){const i=ey(e.projection,e.zoom,e.width,e.height),n=function(e,t,i,n,r){const o=new _u(i.lng-180*ty,i.lat),a=new _u(i.lng+180*ty,i.lat),s=e.project(o.lng,o.lat),l=e.project(a.lng,a.lat),u=-Math.atan2(l.y-s.y,l.x-s.x),c=Iu.fromLngLat(i);c.y=tt(c.y,-1+ty,1-ty);const h=c.toLngLat(),f=e.project(h.lng,h.lat),p=Iu.fromLngLat(h);p.x+=ty;const m=p.toLngLat(),y=e.project(m.lng,m.lat),x=ny(y.x-f.x,y.y-f.y,u),b=Iu.fromLngLat(h);b.y+=ty;const w=b.toLngLat(),E=e.project(w.lng,w.lat),A=ny(E.x-f.x,E.y-f.y,u),I=Math.abs(x.x)/Math.abs(A.y),T=d([]);v(T,T,-u*(1-(r?0:n)));const M=d([]);return g(M,M,[1,1-(1-I)*n,1]),M[4]=-A.x/A.y*n,v(M,M,u),_(M,T,M),M}(e.projection,0,e.center,i,t),r=Qg(e);return g(n,n,[r,r,1]),n}function Qg(e){const t=e.projection,i=ey(e.projection,e.zoom,e.width,e.height),n=iy(t,e.center),r=iy(t,_u.convert(t.center));return Math.pow(2,n*i+(1-i)*r)}function ey(e,t,i,n,r=1/0){const o=e.range;if(!o)return 0;const a=Math.min(r,Math.max(i,n)),s=Math.log2(a/1024);return it(o[0]+s,o[1]+s,t)}const ty=1/4e4;function iy(e,t){const i=tt(t.lat,-85.051129,vu),n=new _u(t.lng-180*ty,i),r=new _u(t.lng+180*ty,i),o=e.project(n.lng,i),a=e.project(r.lng,i),s=Iu.fromLngLat(n),l=Iu.fromLngLat(r),u=a.x-o.x,c=a.y-o.y,h=l.x-s.x,d=l.y-s.y,f=Math.sqrt((h*h+d*d)/(u*u+c*c));return Math.log2(f)}function ny(e,t,i){const n=Math.cos(i),r=Math.sin(i);return {x:e*n-t*r,y:e*r+t*n}}const ry=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function oy(e,t,i){d(e),v(e,e,Ye(t[2])),y(e,e,Ye(t[0])),x(e,e,Ye(t[1])),g(e,e,i),_(e,e,ry);}function ay(e,t,i,n,r,o,a,s){const l=[i[0]-t[0],i[1]-t[1],0],u=[n[0]-t[0],n[1]-t[1],0];if(D(l)<1e-12||D(u)<1e-12)return ce(e);const c=q([],l,u);Z(c,c),L(u,n,t),l[2]=(o-r)*s,u[2]=(a-r)*s;const h=l;return q(h,l,u),Z(h,h),xe(e,c,h)}function sy(e,t,i=!1){const n=Xf(t.zoom),r=function(e,t,i){const n=t.worldSize,r=[e[12],e[13],e[14]],o=pr(r[1]/n),a=fr(r[0]/n),s=d([]),l=yu(1,o)*n,u=yu(1,0)*n*wu(o,t.zoom),c=1/Zf(n);let h=u*c;if(i){const e=ey(t.projection,t.zoom,t.width,t.height,1024);h=c*t.projection.pixelSpaceConversion(t.center.lat,n,e);}const f=du(o,a);O(f,f,k([],Z([],f),l*h*r[2]));const p=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const n=q([],i,t);return q(i,t,n),0===H(i)&&(i=[0,1,0],q(n,t,i)),Z(n,n),Z(i,i),Z(t,t),[n[0],n[1],n[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(f);g(s,s,[h,h,h*l]),m(s,s,[-r[0],-r[1],-r[2]]);const y=_([],t.globeMatrix,p);return _(y,y,s),_(y,y,e),y}(e,t,i);if(n>0){const i=function(e,t){const i=t.worldSize,n=yu(1,0)*i*wu(t.center.lat,t.zoom)/Zf(i),r=yu(1,t.center.lat)*i,o=d([]);x(o,o,Ye(t.center.lng)),y(o,o,Ye(t.center.lat)),m(o,o,[0,0,au]),g(o,o,[n,n,n*r]);const a=t.point;return m(o,o,[-a.x,-a.y,0]),_(o,o,e),_(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const n=(e,t,i)=>{const n=D(e),r=D(t),o=Lf(e,t,i);return k(o,o,1/D(o)*dn(n,r,i))},r=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),a=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),s=Lf([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return [r[0],r[1],r[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],0,s[0],s[1],s[2],1]}(r,i,n)}return r}function ly(e,t,i,n){const r=zf.projectAabbCorners(n,i);let o=Number.MAX_VALUE;for(let e=0;e<r.length;++e){const i=r[e];i[0]=(.5*i[0]+.5)*t.width,i[1]=(.5-.5*i[1])*t.height,i[2]<o&&(o=i[2]);}const a=function(e){const t=[];let i=0;for(let t=1;t<e.length;t++)(e[t][0]<e[i][0]||e[t][0]===e[i][0]&&e[t][1]<e[i][1])&&(i=t);let n,r=i;const o=new Uint8Array(e.length);do{if(o[r])break;t.push(new Pe(e[r][0],e[r][1])),o[r]=1,n=(r+1)%e.length;for(let t=0;t<e.length;t++){if(e[t][0]===e[n][0]&&e[t][1]===e[n][1]||e[t][0]===e[r][0]&&e[t][1]===e[r][1])continue;const i=[e[t][0]-e[r][0],e[t][1]-e[r][1]],o=[e[n][0]-e[r][0],e[n][1]-e[r][1]],a=i[0]*o[1]-i[1]*o[0];(a>0||0===a&&i[0]*o[0]+i[1]*o[1]>=0&&i[0]*i[0]+i[1]*i[1]>o[0]*o[0]+o[1]*o[1])&&(n=t);}r=n;}while(r!==i);return t.length>0&&t.push(t[0]),t}(r);if(Lh(e,a))return o}const uy=64,cy=[1,1,1];function hy(e,t,i,n,r,o,a,s,l,u=!1){const c=i.zoom,h=i.project(n),f=wu(n.lat,c),p=1/f;d(e),m(e,e,[h.x+a[0]*p,h.y+a[1]*p,a[2]]);let y=1,x=1;const v=i.worldSize;if(u){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new Iu(h.x/v,h.y/v),0));const t=le([],[h.x,h.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;y=t,x=t*wu(i.center.lat,c);}else if("globe"===i.projection.name){const t=sy(e,i),r=[0,0,0,1];le(r,r,_([],i.projMatrix,t));const o=r[3]/i.cameraToCenterDistance,a=Xf(c),s=i.projection.pixelsPerMeter(n.lat,v)*wu(n.lat,c),l=i.projection.pixelsPerMeter(i.center.lat,v)*wu(i.center.lat,c);y=o/dn(s,bu(i.center.lat),a),x=o*f/s,y*=l,x*=l;}}else y=p;g(e,e,[y,y,x]);const b=[...e],w=t.orientation,E=[];if(oy(E,[w[0]+(r?r[0]:0),w[1]+(r?r[1]:0),w[2]+(r?r[2]:0)],o),_(e,b,E),s&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(e,t,i,n,r){const o=t.elevation;if(!o)return 0;const a=zf.projectAabbCorners(i,n),s=yu(1,r.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const r of n){const n=e[r.corners[0]],o=e[r.corners[1]],a=e[r.corners[2]],s=[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])],l=q(s,s,[a[0]-n[0],a[1]-n[1],t*(a[2]-n[2])]);Z(l,l),r.dotProductWithUp=W(l,i);}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(a,s),u=a[l[0]],c=a[l[1]],h=a[l[2]],d=a[l[3]],f=o.getAtPointOrZero(new Iu(u[0]/t.worldSize,u[1]/t.worldSize),0),p=o.getAtPointOrZero(new Iu(c[0]/t.worldSize,c[1]/t.worldSize),0),_=o.getAtPointOrZero(new Iu(h[0]/t.worldSize,h[1]/t.worldSize),0),m=o.getAtPointOrZero(new Iu(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(f+m)/2,y=(p+_)/2;return g>y?p<_?ay(e,c,d,u,p,m,f,s):ay(e,h,u,d,_,f,m,s):f<m?ay(e,u,c,h,f,p,_,s):ay(e,d,h,c,m,_,p,s),Math.max(g,y)}(o,i,t.aabb,e,n);const a=_([],T([],o),E);_(e,b,a);}else r=i.elevation.getAtPointOrZero(new Iu(h.x/v,h.y/v),0);0!==r&&(e[14]+=r);}}class dy{constructor(e,t,i,n,r){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=null!=i?new _u(i[0],i[1]):new _u(0,0),this.orientation=n??[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,t){_(e.globalMatrix,t,e.localMatrix);const i=this.nodeOverrides.get(e.name);if(void 0!==i){if(i.orientation){const t=[];r=i.orientation,d(n=t),x(n,n,Ye(r[1])),v(n,n,Ye(r[2])),y(n,n,Ye(r[0])),_(e.globalMatrix,e.globalMatrix,t);}i.minZoom&&(e.minZoom=i.minZoom),i.maxZoom&&(e.maxZoom=i.maxZoom);}var n,r;if(e.meshes)for(const t of e.meshes){const i=zf.applyTransformFast(t.aabb,e.globalMatrix);this.aabb.encapsulate(i);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.globalMatrix);}computeBoundsAndApplyParent(){const e=d([]);this.aabb=new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const t of this.nodes)this._applyTransformations(t,e);}computeModelMatrix(e,t,i,n,r,o,a=!1){hy(this.matrix,this,e.transform,this.position,t,i,n,r,o,a);}upload(e){if(!this.uploaded){for(const t of this.nodes)_y(t,e);for(const e of this.nodes)gy(e);this.uploaded=!0;}}destroy(){for(const e of this.nodes)xy(e);}}function fy(e,t,i=!1){e.uploaded||(e.gfxTexture=new p_(t,e.image,i?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function py(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,$g.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Xg.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,qg.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Zg:Wg).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Jg.members,!0)),e.segments=Uc.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&fy(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&fy(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&fy(n.normalTexture,t),n.occlusionTexture&&fy(n.occlusionTexture,t,i),n.emissionTexture&&fy(n.emissionTexture,t);}function _y(e,t,i){if(e.meshes)for(const n of e.meshes)py(n,t,i);if(e.lodMeshes)for(const n of e.lodMeshes)py(n,t,i);if(e.children)for(const n of e.children)_y(n,t,i);}function my(e){e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();}function gy(e){if(e.meshes)for(const t of e.meshes)my(t);if(e.lodMeshes)for(const t of e.lodMeshes)my(t);if(e.children)for(const t of e.children)gy(t);}function yy(e){var t;e.vertexBuffer&&(e.vertexBuffer.destroy(),e.indexBuffer.destroy(),e.normalBuffer&&e.normalBuffer.destroy(),e.texcoordBuffer&&e.texcoordBuffer.destroy(),e.colorBuffer&&e.colorBuffer.destroy(),e.pbrBuffer&&e.pbrBuffer.destroy(),e.segments.destroy(),e.material&&((t=e.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));}function xy(e){if(e.meshes)for(const t of e.meshes)yy(t);if(e.lodMeshes)for(const t of e.lodMeshes)yy(t);if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)xy(t);}function vy(e,t,i,n){return e[0]<=n[0]&&t[0]>=i[0]&&e[1]<=n[1]&&t[1]>=i[1]&&e[2]<=n[2]&&t[2]>=i[2]}function by(e,t,i,n,r,o,a,s,l,u,c){const h=.5*(u[0]+c[0]),d=.5*(u[1]+c[1]),f=.5*(u[2]+c[2]),p=.5*(c[0]-u[0]),_=.5*(c[1]-u[1]),m=.5*(c[2]-u[2]),g=e-h,y=t-d,x=i-f,v=n-h,b=r-d,w=o-f,E=a-h,A=s-d,I=l-f,T=v-g,M=b-y,S=w-x,z=E-v,R=A-b,P=I-w,D=g-E,C=y-A,F=x-I;let O,L,B,N,V,k;if(O=x*M-y*S,L=w*M-b*S,B=I*M-A*S,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(S)*_+Math.abs(M)*m,N>k||V<-k)return !1;if(O=x*R-y*P,L=w*R-b*P,B=I*R-A*P,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(P)*_+Math.abs(R)*m,N>k||V<-k)return !1;if(O=x*C-y*F,L=w*C-b*F,B=I*C-A*F,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(F)*_+Math.abs(C)*m,N>k||V<-k)return !1;if(O=g*S-x*T,L=v*S-w*T,B=E*S-I*T,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(S)*p+Math.abs(T)*m,N>k||V<-k)return !1;if(O=g*P-x*z,L=v*P-w*z,B=E*P-I*z,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(P)*p+Math.abs(z)*m,N>k||V<-k)return !1;if(O=g*F-x*D,L=v*F-w*D,B=E*F-I*D,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(F)*p+Math.abs(D)*m,N>k||V<-k)return !1;if(O=y*T-g*M,L=b*T-v*M,B=A*T-E*M,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(M)*p+Math.abs(T)*_,N>k||V<-k)return !1;if(O=y*z-g*R,L=b*z-v*R,B=A*z-E*R,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(R)*p+Math.abs(z)*_,N>k||V<-k)return !1;if(O=y*D-g*C,L=b*D-v*C,B=A*D-E*C,N=Math.min(O,L,B),V=Math.max(O,L,B),k=Math.abs(C)*p+Math.abs(D)*_,N>k||V<-k)return !1;if(N=Math.min(g,v,E),V=Math.max(g,v,E),N>p||V<-p)return !1;if(N=Math.min(y,b,A),V=Math.max(y,b,A),N>_||V<-_)return !1;if(N=Math.min(x,w,I),V=Math.max(x,w,I),N>m||V<-m)return !1;const U=M*P-S*R,G=S*z-T*P,j=T*R-M*z,H=-(U*g+G*y+j*x);return k=p*Math.abs(U)+_*Math.abs(G)+m*Math.abs(j),!(Math.abs(H)>k)}const wy=[];class Ey{serializeFromGltf(e,t,i,n){if(e.length<7)return;let r=0;if(109!==e[r++]||98!==e[r++]||120!==e[r++]||98!==e[r++]||118!==e[r++]||104!==e[r++])return;if(43!==e[r++])return;const o=new DataView(e.buffer,e.byteOffset),a=o.getUint16(r,!0);if(r+=2,0===a)return;this._nodes=[];let s=0;for(let e=0;e<a;e++){const e=[t[3*s],t[3*s+1],t[3*s+2]],n=[i[3*s],i[3*s+1],i[3*s+2]];s++;const a=o.getUint16(r,!0);r+=2;let l=0,u=0;65535===a&&(l=o.getUint16(r,!0),r+=2,u=o.getUint32(r,!0),r+=4),this._nodes.push({aabbMin:e,aabbMax:n,backChild:a,indexCount:l,indexOffset:u});}const l=o.getUint32(r,!0);this._indices=n.slice(0,l);}setVertices(e){this._vertices=e;}findHighestPoint(e,t){if(!this._nodes||0===this._nodes.length)return null;if(!vy(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,t))return null;const i=wy;i.length=0,i.push(0);let n=-1/0;for(;i.length>0;){const r=i.pop(),o=this._nodes[r];if(o.aabbMax[2]<=n)continue;if(65535===o.backChild){for(let i=0;i<o.indexCount;i+=3){const r=3*this._indices[o.indexOffset+i],a=3*this._indices[o.indexOffset+i+1],s=3*this._indices[o.indexOffset+i+2];by(this._vertices[r],this._vertices[r+1],this._vertices[r+2],this._vertices[a],this._vertices[a+1],this._vertices[a+2],this._vertices[s],this._vertices[s+1],this._vertices[s+2],e,t)&&(n=Math.max(n,this._vertices[r+2],this._vertices[a+2],this._vertices[s+2]));}continue}const a=r+1,s=o.backChild,l=this._nodes[a],u=this._nodes[s],c=vy(l.aabbMin,l.aabbMax,e,t),h=vy(u.aabbMin,u.aabbMax,e,t);c&&h?l.aabbMax[2]<u.aabbMax[2]?(i.push(a),i.push(s)):(i.push(s),i.push(a)):c?i.push(a):h&&i.push(s);}return n>=0?n:null}}function Ay(e,t){const i=e.json.bufferViews[t.bufferView],n=Mg[t.componentType];return new n(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==zg[t.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:zg[t.type]))}function Iy(e,t,i,n){const r=Mg[t.componentType],o=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),a=e.json.bufferViews[t.bufferView],s=a.byteStride?a.byteStride/r.BYTES_PER_ELEMENT:zg[t.type],l=i.float32,u=l.length/i.capacity,c=t.count*s;for(let e=0,t=0;e<c;e+=s,t+=u)for(let i=0;i<u;i++)l[t+i]=n[e+i]*o;}function Ty(e,t,i){const n=e.indices,r=e.attributes,o={};o.indexArray=new uc;const a=t.json.accessors[n],s=Ay(t,a);o.indexArray.resizeExact(a.count/3),o.indexArray.uint16.set(s),o.vertexArray=new Yu;const l=t.json.accessors[r.POSITION],u=Ay(t,l);o.vertexArray.resizeExact(l.count),o.vertexArray.float32.set(u),o.aabb=new zf(l.min,l.max);const[c,h,d]=l.min,[f,p,_]=l.max;if(o.centroid=[.5*(c+f),.5*(h+p),.5*(d+_)],void 0!==r.COLOR_0){const e=t.json.accessors[r.COLOR_0],i=zg[e.type],n=Ay(t,e);o.colorArray=3===i?new Yu:new ic,o.colorArray.resizeExact(e.count),Iy(t,e,o.colorArray,n);}if(void 0!==r.NORMAL){o.normalArray=new Yu;const e=t.json.accessors[r.NORMAL];o.normalArray.resizeExact(e.count);const i=Ay(t,e);Iy(t,e,o.normalArray,i);}if(void 0!==r.TEXCOORD_0&&i.length>0){o.texcoordArray=new gc;const e=t.json.accessors[r.TEXCOORD_0];o.texcoordArray.resizeExact(e.count);const i=Ay(t,e);Iy(t,e,o.texcoordArray,i);}if(void 0!==r._FEATURE_ID_RGBA4444){const e=t.json.accessors[r._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=Ay(t,e));}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(Ay(t,t.json.accessors[r._FEATURE_RGBA4444]).buffer));const m=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:a,emissiveTexture:s,doubleSided:l,name:u}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:f,metallicRoughnessTexture:p}=e.pbrMetallicRoughness||{},_=a?t[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&_){const e=a.extensions.KHR_texture_transform;_.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]];}return {name:u,pbrMetallicRoughness:{baseColorFactor:new pn(...c),metallicFactor:h,roughnessFactor:d,baseColorTexture:f?t[f.index]:void 0,metallicRoughnessTexture:p?t[p.index]:void 0},doubleSided:l,emissiveFactor:new pn(...i),alphaMode:n,alphaCutoff:r,normalTexture:o?t[o.index]:void 0,occlusionTexture:_,emissionTexture:s?t[s.index]:void 0,defined:void 0===e.defined}}(void 0!==m?t.json.materials[m]:{defined:!1},i),o}function My(e,t,i){const{matrix:n,rotation:r,translation:o,scale:a,mesh:s,extras:l,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,i,n){var r=t[0],o=t[1],a=t[2],s=t[3],l=r+r,u=o+o,c=a+a,h=r*l,d=r*u,f=r*c,p=o*u,_=o*c,m=a*c,g=s*l,y=s*u,x=s*c,v=n[0],b=n[1],w=n[2];return e[0]=(1-(p+m))*v,e[1]=(d+x)*v,e[2]=(f-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(h+m))*b,e[6]=(_+g)*b,e[7]=0,e[8]=(f+y)*w,e[9]=(_-g)*w,e[10]=(1-(h+p))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],r||[0,0,0,1],o||[0,0,0],a||[1,1,1]),d.globalMatrix=c(d.localMatrix),void 0!==s){d.meshes=i[s];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:n}=t.aabb;e[0]+=i[0]+n[0],e[1]+=i[1]+n[1];}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2);}if(l&&(l.id&&(d.id=l.id),l.lights&&(d.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.codePointAt(e);return i}(e),i=[],n=t.length/24,r=new Uint16Array(t.buffer),o=new Float32Array(t.buffer);for(let e=0;e<n;e++){const t=r[2*e*6]/30,n=r[2*e*6+1]/30,a=r[2*e*6+10]/100,s=o[6*e+1],l=o[6*e+2],u=o[6*e+3],c=o[6*e+4],h=u-s,d=c-l,f=Math.hypot(h,d);i.push({pos:[s+.5*h,l+.5*d,n],normal:[d/f,-h/f,0],width:f,height:t,depth:a,points:[s,l,u,c]});}return i}(l.lights)),l.MAPBOX_geometry_bloom&&(d.isGeometryBloom=l.MAPBOX_geometry_bloom),l.MAPBOX_zoom_min&&(d.minZoom=l.MAPBOX_zoom_min),l.MAPBOX_zoom_max&&(d.maxZoom=l.MAPBOX_zoom_max)),u){const e=[];for(const n of u)e.push(My(t.json.nodes[n],t,i));d.children=e;}if(e.extensions&&e.extensions.mbx_bvh&&(d.meshBVH=function(e,t,i){const n=t.binaryAccessor,r=t.positionMinAccessor,o=t.positionMaxAccessor,a=t.indexAccessor;if(!(Number.isInteger(n)&&Number.isInteger(r)&&Number.isInteger(o)&&Number.isInteger(a)))return null;const s=e.json.accessors;if(n>=s.length||r>=s.length||o>=s.length||a>=s.length)return null;const l=s[n],u=s[r],c=s[o],h=s[a];if(void 0===l.bufferView||void 0===u.bufferView||void 0===c.bufferView||void 0===h.bufferView)return null;const d=e.json.bufferViews;if(l.bufferView>=d.length||u.bufferView>=d.length||c.bufferView>=d.length||h.bufferView>=d.length)return null;const f=d[l.bufferView],p=d[u.bufferView],_=d[c.bufferView],m=d[h.bufferView];if(f.buffer>=e.buffers.length||p.buffer>=e.buffers.length||_.buffer>=e.buffers.length||m.buffer>=e.buffers.length)return null;const g=(e,t,i)=>e>=0&&e<=i&&t<=i-e,y=l.byteOffset||0,x=u.byteOffset||0,v=c.byteOffset||0,b=h.byteOffset||0;if(!(g(y,0,f.byteLength)&&g(x,3*u.count*4,p.byteLength)&&g(v,3*c.count*4,_.byteLength)&&g(b,4*h.count,m.byteLength)))return null;const w=new Uint8Array(e.buffers[f.buffer],(f.byteOffset||0)+y,f.byteLength-y),E=new Float32Array(e.buffers[p.buffer],(p.byteOffset||0)+x,3*u.count),A=new Float32Array(e.buffers[_.buffer],(_.byteOffset||0)+v,3*c.count),I=new Uint32Array(e.buffers[m.buffer],(m.byteOffset||0)+b,h.count),T=new Ey;if(T.serializeFromGltf(w,E,A,I),void 0!==i&&e.json.meshes&&e.json.meshes[i]){const t=e.json.meshes[i].primitives[0];if(t&&void 0!==t.attributes.POSITION&&t.attributes.POSITION<s.length){const i=s[t.attributes.POSITION];if(void 0!==i.bufferView&&i.bufferView<d.length){const t=d[i.bufferView];if(t.buffer<e.buffers.length){const n=i.byteOffset||0,r=t.byteStride?t.byteStride/4:3;if(g(n,i.count*r*4,t.byteLength)){const o=(t.byteOffset||0)+n;if(3===r)T.setVertices(new Float32Array(e.buffers[t.buffer],o,3*i.count));else {const n=new Float32Array(e.buffers[t.buffer],o,i.count*r),a=new Float32Array(3*i.count);for(let e=0;e<i.count;e++)a[3*e]=n[e*r],a[3*e+1]=n[e*r+1],a[3*e+2]=n[e*r+2];T.setVertices(a);}}}}}}return T}(t,e.extensions.mbx_bvh,s)),!d.meshBVH&&d.children)for(const e of d.children)if(e.meshBVH){d.meshBVH=e.meshBVH;break}return d}function Sy(e){if(0===e.vertices.length||0===e.indices.length)return null;const t=new jg(e.vertices,e.indices,8,256),[i,n]=[t.min.clone(),t.max.clone()];return {vertices:e.vertices,indices:e.indices,grid:t,min:i,max:n}}function zy(e){if(!e.extras||!e.extras.ground)return null;const t=e.extras.ground;if(!t||!Array.isArray(t)||0===t.length)return null;const i=t[0];if(!i||!Array.isArray(i)||0===i.length)return null;const n=[];for(const e of i){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],i=e[1];"number"==typeof t&&"number"==typeof i&&n.push(new Pe(t,i));}if(n.length<3)return null;n.length>1&&n.at(-1).equals(n[0])&&n.pop();let r=0;for(let e=0;e<n.length;e++){const t=n[e],i=n[(e+1)%n.length],o=n[(e+2)%n.length];r+=(t.x-i.x)*(o.y-i.y)-(o.x-i.x)*(t.y-i.y);}r>0&&n.reverse();const o=Pl(n.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ry(e,t){const i=[],n=[];let r=0;const o=[];for(const a of e){r=i.length;const e=a.vertexArray.float32,s=a.indexArray.uint16;for(let n=0;n<a.vertexArray.length;n++)o[0]=e[3*n+0],o[1]=e[3*n+1],o[2]=e[3*n+2],Y(o,o,t),i.push(new Pe(o[0],o[1]));for(let e=0;e<3*a.indexArray.length;e++)n.push(s[e]+r);}if(n.length%3!=0)return null;for(let e=0;e<n.length;e+=3){const t=i[n[e+0]],r=i[n[e+1]],o=i[n[e+2]];(t.x-r.x)*(o.y-r.y)-(o.x-r.x)*(t.y-r.y)>0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]]);}return {vertices:i,indices:n}}function Py(e,t){for(let i=0;i<e.length;i++)if(e[i].name===t)return i;return -1}function Dy(e){const t=function(e,t){const i=[],n=WebGL2RenderingContext;if(e.json.textures)for(const r of e.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,e.json.samplers[r.sampler]),i.push({image:t[r.source],sampler:o,uploaded:!1});}return i}(e,e.images),i=function(e,t){const i=[];if(!e.json.meshes)return i;for(const n of e.json.meshes){const r=[];for(const i of n.primitives)r.push(Ty(i,e,t));i.push(r);}return i}(e,t),{scenes:n,scene:r,nodes:o}=e.json;let a=n?Py(n,"Default Scene"):-1;a<0&&(a=r||0);const s=n&&n[a]?n[a].nodes||[]:[...o.keys()],l=[];for(const t of s)l.push(My(o[t],e,i));!function(e,t,i){const n={},r=new Set;for(let o=0;o<e.length;o++){const e=i[t[o]];if(!e.extras)continue;const a=e.extras["mapbox:footprint:version"],s=e.extras["mapbox:footprint:id"];(a||s)&&r.add(o),"1.0.0"===a&&s&&(n[s]=o);}for(let o=0;o<e.length;o++){if(r.has(o))continue;const a=e[o],s=i[t[o]];if(!s.extras)continue;let l=null;a.id in n&&(l=Ry(e[n[a.id]].meshes,a.localMatrix)),l||(l=zy(s)),l&&(a.footprint=Sy(l));}if(r.size>0){const t=Array.from(r.values()).sort((e,t)=>e-t);for(let i=t.length-1;i>=0;i--)e.splice(t[i],1);}}(l,s,e.json.nodes);const u=n?Py(n,"LOD"):-1;if(u>=0){const t=n[u].nodes,r=new Map;for(const n of t){const t=My(o[n],e,i);t.id&&r.set(t.id,t);}for(const e of l)if(e.id){const t=r.get(e.id);t&&t.meshes&&(e.lodMeshes=t.meshes,t.meshBVH&&(e.meshBVH=t.meshBVH));}}return l}function Cy(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,n=e.aabb.min[1]-1,r=uy/(e.aabb.max[0]-i+2),o=uy/(e.aabb.max[1]-n+2);for(let a=0;a<t.length;a+=3){const s=t[a+2],l=(t[a+0]-i)*r|0,u=(t[a+1]-n)*o|0;s>e.heightmap[u*uy+l]&&(e.heightmap[u*uy+l]=s);}}function Fy(e,t,i,n,r){i.reserve(i.length+4*e.length),n.reserve(n.length+10*e.length),r.reserve(r.length+10*e.length);let o=n.length;for(const a of e){const e=Math.min(10,Math.max(4,1.3*a.height))*t,s=[-a.normal[1],a.normal[0],0],l=Math.min(.29,.1*a.width/a.depth),u=a.width-2*a.depth*t*(l+.01),c=U([],a.pos,s,u/2),h=U([],a.pos,s,-u/2),d=[c[0],c[1],c[2]+a.height],f=[h[0],h[1],h[2]+a.height],p=U([],a.normal,s,l);k(p,p,e);const _=U([],a.normal,s,-l);k(_,_,e),O(p,c,p),O(_,h,_),c[2]+=.1,h[2]+=.1,n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(_[0],_[1],_[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(_[0],_[1],_[2]);const m=u/e/2;r.emplaceBack(-m-l,-1,m,.8),r.emplaceBack(m+l,-1,m,.8),r.emplaceBack(-m,0,m,1.3),r.emplaceBack(m,0,m,1.3),r.emplaceBack(m+l,-.8,m,.7),r.emplaceBack(m+l,-.8,m,.7),r.emplaceBack(0,0,m,1.3),r.emplaceBack(0,0,m,1.3),r.emplaceBack(m+l,-1.2,m,.8),r.emplaceBack(m+l,-1.2,m,.8),i.emplaceBack(6+o,4+o,8+o),i.emplaceBack(7+o,9+o,5+o),i.emplaceBack(0+o,1+o,2+o),i.emplaceBack(1+o,3+o,2+o),o+=10;}}function Oy(e,t){const i={};i.indexArray=new uc,i.vertexArray=new Yu,i.colorArray=new ic,i.indexArray.reserveExact(4*e.length),i.vertexArray.reserveExact(10*e.length),i.colorArray.reserveExact(10*e.length),Fy(e,t,i.indexArray,i.vertexArray,i.colorArray);const n={defined:!0};n.emissiveFactor=pn.black;const r={};return r.baseColorFactor=pn.white,n.pbrMetallicRoughness=r,i.material=n,i.aabb=new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}qa(Ey,"ModelBVH");const Ly=Vu([{name:"a_pos_3f",components:3,type:"Float32"}]),By=Vu([{name:"a_normal_3",components:3,type:"Int16"}]),Ny=Vu([{name:"a_centroid_3",components:3,type:"Int16"}]),Vy=Vu([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ky=Vu([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Uy=Vu([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Gy=Vu([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),jy=Vu([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Hy=Vu([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),$y=Vu([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Zy=Vu([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Wy=Vu([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),qy=Vu([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Xy=Vu([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Yy=Vu([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Jy=Vu([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Ky}=$y;function Qy(e,t,i,n){const r=[],o=0===n?(e,t,i,n,r,o)=>{e.push(new Pe(o,i+(o-t)/(n-t)*(r-i)));}:(e,t,i,n,r,o)=>{e.push(new Pe(t+(o-i)/(r-i)*(n-t),o));};for(const a of e){const e=[];for(const r of a){if(r.length<=2)continue;const a=[];for(let e=0;e<r.length-1;e++){const s=r[e].x,l=r[e].y,u=r[e+1].x,c=r[e+1].y,h=0===n?s:l,d=0===n?u:c;h<t?d>t&&o(a,s,l,u,c,t):h>i?d<i&&o(a,s,l,u,c,i):a.push(r[e]),d<t&&h>=t&&o(a,s,l,u,c,t),d>i&&h<=i&&o(a,s,l,u,c,i);}let s=r.at(-1);const l=0===n?s.x:s.y;l>=t&&l<=i&&a.push(s),a.length&&(s=a.at(-1),a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a));}e.length&&r.push(e);}return r}const ex={None:0,Model:1,Symbol:2,FillExtrusion:4},tx=[new Pe(0,0),new Pe(Sr,0),new Pe(Sr,Sr),new Pe(0,Sr)];function ix(e,t){const i=[];let n=[];if(!t||e.length<2)return [e];if(2===e.length)return Xh(e[0],e[1],tx)?[e]:[];for(let t=0;t<e.length+2;t++){const r=0===t?e.at(-1):e[(t-1)%e.length],o=e[t%e.length],a=e[(t+1)%e.length],s=Xh(r,o,tx),l=Xh(o,a,tx),u=s||l;u&&n.push(o),u&&l||n.length>0&&(n.length>1&&i.push(n),n=[]);}return n.length>1&&i.push(n),i}const nx=Ph.types,rx=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],ox=["fill-extrusion-flood-light-ground-radius"],ax=Math.pow(2,13),sx=Math.pow(2,15)-1,lx=new Pe(0,1),ux=2147483648,cx=1073741824;function hx(e,t,i,n,r,o,a,s){e.emplaceBack((t<<1)+a,(i<<1)+o,(Math.floor(n*ax)<<1)+r,Math.round(s));}function dx(e,t,i){e.emplaceBack(t.x*Sr,t.y*Sr,i?1:0);}function fx(e,t,i,n,r,o){e.emplaceBack(t.x,t.y,(i.x<<1)+n,(i.y<<1)+r,o);}function px(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n);}class _x{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class mx{constructor(){this.data=[];}get length(){return this.data.length}push(e){this.data.push(e);}get(e){return this.data[e]}static serialize(e,t){const i=e.data.length,n=new Uint32Array(4*i),r=[];r.length=i;for(let t=0;t<i;t++){const i=e.data[t],o=4*t;n[o]=i.vertexOffset,n[o+1]=i.vertexCount,n[o+2]=i.indexOffset,n[o+3]=i.indexCount,r[t]=i.ringIndices;}return t&&t.add(n.buffer),{scalars:n,rings:r}}static deserialize(e){const{scalars:t,rings:i}=e,n=t.length/4,r=new mx,o=[];o.length=n,r.data=o;for(let e=0;e<n;e++){const n=4*e,o=new _x;o.vertexOffset=t[n],o.vertexCount=t[n+1],o.indexOffset=t[n+2],o.indexCount=t[n+3],o.ringIndices=i[e],r.data[e]=o;}return r}}class gx{constructor(){this.centroidXY=new Pe(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Pe(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Pe(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Pe(0,0);}span(){return new Pe(this.max.x-this.min.x,this.max.y-this.min.y)}}class yx{constructor(){this.data=[],this.buffer=null;}get length(){return this.data.length}push(e){this.data.push(e);}get(e){return this.data[e]}find(e){return this.data.find(e)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(e,t){const i=e.data.length,n=new Float64Array(15*i);for(let t=0;t<i;t++){const i=e.data[t],r=15*t;n[r]=i.centroidXY.x,n[r+1]=i.centroidXY.y,n[r+2]=i.min.x,n[r+3]=i.min.y,n[r+4]=i.max.x,n[r+5]=i.max.y,n[r+6]=i.groupCentroidPos.x,n[r+7]=i.groupCentroidPos.y,n[r+8]=i.vertexArrayOffset,n[r+9]=i.vertexCount,n[r+10]=i.groundVertexArrayOffset,n[r+11]=i.groundVertexCount,n[r+12]=i.footprintSegLen,n[r+13]=i.height,n[r+14]=i.buildingId;}return t&&t.add(n.buffer),{buffer:n}}static deserialize(e){const t=e.buffer,i=t.length/15,n=new yx;n.buffer=t;const r=[];r.length=i,n.data=r;let o=0;for(let e=0;e<i;e++){const i=15*e,r=new gx;r.centroidXY=new Pe(t[i],t[i+1]),r.min=new Pe(t[i+2],t[i+3]),r.max=new Pe(t[i+4],t[i+5]),r.groupCentroidPos=new Pe(t[i+6],t[i+7]),r.vertexArrayOffset=t[i+8],r.vertexCount=t[i+9],r.groundVertexArrayOffset=t[i+10],r.groundVertexCount=t[i+11],r.footprintSegLen=t[i+12],r.height=t[i+13],r.buildingId=t[i+14],r.footprintSegIdx=o,o+=r.footprintSegLen,n.data[e]=r;}return n}}class xx{constructor(){this.acc=new Pe(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y);}appendEdge(e,t,i){this.accCount++,this.acc._add(t);let n=!!this.borders;t.x<e.min.x?(e.min.x=t.x,n=!0):t.x>e.max.x&&(e.max.x=t.x,n=!0),t.y<e.min.y?(e.min.y=t.y,n=!0):t.y>e.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Sr)&&t.x===i.x)!=((0===t.y||t.y===Sr)&&t.y===i.y)&&this.processBorderOverlap(t,i),n&&this.checkBorderIntersection(t,i);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,dn(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Sr!=e.x>Sr&&this.addBorderIntersection(1,dn(t.y,e.y,(Sr-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,dn(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Sr!=e.y>Sr&&this.addBorderIntersection(3,dn(t.x,e.x,(Sr-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y);}else {const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x);}}centroid(){return 0===this.accCount?new Pe(0,0):new Pe(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function vx(e,t){const i=e.add(t)._unit(),n=tt(e.x*i.x+e.y*i.y,-1,1);var r,o,a;return a=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(a)))/4*sx*((r=e).x*(o=t).y-r.y*o.x<0?-1:1)}const bx=[e=>e.x<0,e=>e.x>Sr,e=>e.y<0,e=>e.y>Sr];function wx(e,t,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=e.sub(i),a=t.sub(i),s=[e,t,o,a];for(let e=0;e<4;e++)for(const t of s)if(bx[e](t)){r.push(e);break}return r}class Ex{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new qu,this.indexArray=new uc,this.programConfigurations=new ph(e.layers,{zoom:e.zoom,lut:e.lut},e=>ox.includes(e)),this._segments=new Uc,this.hiddenByLandmarkVertexArray=new Ec,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Uc;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,n=!1){const r=e.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let s;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];s=vx(t.sub(e[r-1])._perp()._unit(),i.sub(t)._perp()._unit());}for(let l=0;l<r;l++){const u=l===r-1?0:l+1,c=e[l],h=e[u],d=e[u===r-1?0:u+1],f=h.sub(c)._perp()._unit(),p=vx(f,d.sub(h)._perp()._unit()),_=s,m=p;if(Px(c,h,t)||n&&Dx(c,t)&&Dx(h,t)){s=p;continue}const g=a.vertexLength;fx(this.vertexArray,c,h,1,1,_),fx(this.vertexArray,c,h,1,0,_),fx(this.vertexArray,c,h,0,1,m),fx(this.vertexArray,c,h,0,0,m),a.vertexLength+=4;const y=wx(c,h,f,i);for(const e of y)this._segmentToGroundQuads[o].push({id:g,region:e}),this._segmentToRegionTriCounts[o][e]+=2,a.primitiveLength+=2;s=p;}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let e=0;e<t;e++)this._segmentToGroundQuads[e].sort((e,t)=>e.region-t.region);for(let i=0;i<t;i++){const t=this._segmentToGroundQuads[i],n=e[i],r=this._segmentToRegionTriCounts[i];r.reduce((e,t)=>e+t,0);let o=0;for(let e=0;e<=4;e++){const t=r[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new Uc);const r={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+o,vertexLength:n.vertexLength,primitiveLength:t};i.get().push(r);}o+=t;}for(let e=0;e<t.length;e++){const i=t[e].id;this.indexArray.emplaceBack(i,i+1,i+3),this.indexArray.emplaceBack(i,i+3,i+2);}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null;}addPaintPropertiesData(e,t,i,n,r,o,a){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,i,n,r,o,void 0,a);}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Zy.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,Wy.members)));}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e);}update(e,t,i,n,r,o,a,s){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,i,n,r,o,a,s);}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&ux||e.flags&cx));}updateHiddenByLandmarkRange(e,t,i){if(!this.hasData())return;const n=t+e;if(0!==t){for(let t=e;t<n;++t)this.hiddenByLandmarkVertexArray.emplace(t,i?1:0);this._needsHiddenByLandmarkUpdate=!0;}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Yy.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class Ax{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new yx,this.footprintIndices=new uc,this.footprintVertices=new Uu,this.footprintSegments=new mx,this.layoutVertexArray=new Wu,this.centroidVertexArray=new Fc,this.wallVertexArray=new Lc,this.indexArray=new uc,this.programConfigurations=new ph(e.layers,{zoom:e.zoom,lut:e.lut},e=>rx.includes(e)),this.segments=new Uc,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new Ex(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.features=[],this.hasPattern=ru("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Au(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Fu(r,e);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const u={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Cu(r,i,n),properties:r.properties,type:r.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===nx[u.type];if(this.hasPattern)this.features.push({featureId:r.id,feature:ou("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of u.geometry)for(const o of ix(e,h))this.addFeature(r.id,u,[o],a,i,{},t.availableImages,n,t.brightness);else this.addFeature(r.id,u,u.geometry,a,i,{},t.availableImages,n,t.brightness);t.featureIndex.insert(r,u.geometry,a,s,this.index,c);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,i,n,r,o){for(const{featureId:e,feature:a}of this.features){const s="Polygon"===nx[a.type],{geometry:l}=a;if(this.wallMode)for(const u of l)for(const l of ix(u,s))this.addFeature(e,a,[l],a.index,t,i,n,r,o);else this.addFeature(e,a,l,a.index,t,i,n,r,o);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,i,n,r,o,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a,this.worldview),this.groundEffect.update(e,t,r,i,n,o,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ky),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Xy.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Jy.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,qy.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,i,n,r,o,a,s,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Pe(0,0),new Pe(Sr,Sr)],h=s.projection,d="globe"===h.name,f=this.wallMode||"Polygon"===nx[t.type],p=new xx;p.centroidDataIndex=this.centroidData.length;const _=new gx;_.buildingId=e,t.properties&&Object.hasOwn(t.properties,"building_id")&&(_.buildingId=Number(t.properties.building_id)),p.buildingId=_.buildingId;const m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},r)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},r);let y;if(_.height=g,_.vertexArrayOffset=this.layoutVertexArray.length,_.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Qu),this.wallMode){if(d)return void mt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;y=function(e){const t=e[0].x===e.at(-1).x&&e[0].y===e.at(-1).y,i=function(e){let t=0;const i=e.length;for(let n=0;n<i;n++)t+=(e[(n+1)%i].x-e[n].x)*(e[(n+1)%i].y+e[n].y);return t>=0}(e);i||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],a=[];let s=e.length;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;if(s<(t?3:2))return n;let l,u,c,h,d,f=0;for(;f<s-1&&e[f].equals(e[f+1]);)f++;t&&(l=e[s-2],d=e[f].sub(l)._unit()._perp());for(let i=f;i<s;i++){if(c=i===s-1?t?e[f+1]:void 0:e[i+1],c&&e[i].equals(c))continue;d&&(h=d),l&&(u=l),l=e[i],d=c?c.sub(l)._unit()._perp():h,h=h||d;let n=h.add(d);0===n.x&&0===n.y||n._unit();const p=n.x*d.x+n.y*d.y,_=0!==p?1/p:1/0,m=h.x*d.y-h.y*d.x>0;let g="miter";const y=2;"miter"===g&&_>y&&(g="bevel"),"bevel"===g&&(_>100&&(g="flipbevel"),_<y&&(g="miter"));const x=(e,t,i,n)=>{const s=new Pe(e.x,e.y),l=new Pe(e.x,e.y);s.x+=t.x*n,s.y+=t.y*n,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),a.push(t),r.push(s),o.push(l);};if("miter"===g)n._mult(_),x(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),x(l,n,0,0),x(l,n.mult(-1),0,0);else {const e=-Math.sqrt(_*_-1),t=m?e:0,i=m?0:e;u&&x(l,h,t,i),c&&x(l,d,t,i);}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...a,...a.reverse(),a.at(-1)];const p=n.geometry.length-1;for(let e=0;e<p/2;e++)if(e+1<p/2){let t=e,i=e+1,r=p-1-e,o=p-2-e;t=0===t?p-1:t-1,i=0===i?p-1:i-1,r=0===r?p-1:r-1,o=0===o?p-1:o-1,n.indices.push(r),n.indices.push(i),n.indices.push(t),n.indices.push(r),n.indices.push(o),n.indices.push(i);}return n}(i[0]),i=[y.geometry];}const x=(e,t)=>e<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:Ne(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||Cx(t[0]))&&v.splice(e,1);}let b;if(d)b=Bx(v,c,r);else {b=[];for(const e of v)b.push({polygon:e,bounds:c});}const w=f?this.edgeRadius:0,E=w>0&&this.zoom<17,A=(e,t)=>{if(0===e.length)return !1;const i=e.at(-1);return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of b){let i=0,n=0;for(const t of e)f&&!t[0].equals(t.at(-1))&&t.push(t[0]),n+=f?t.length-1:t.length;const o=this.segments.prepareSegment((f?5:4)*n,this.layoutVertexArray,this.indexArray);_.footprintSegIdx<0&&(_.footprintSegIdx=this.footprintSegments.length),_.polygonSegIdx<0&&(_.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},s=new _x;if(s.vertexOffset=this.footprintVertices.length,s.indexOffset=3*this.footprintIndices.length,s.ringIndices=[],f){const n=[],a=[];i=o.vertexLength;for(let i=0;i<e.length;i++){const l=e[i];l.length&&0!==i&&a.push(n.length/2);const c=[];let f,p;f=l[1].sub(l[0])._perp()._unit(),s.ringIndices.push(l.length-1);for(let e=1;e<l.length;e++){const t=l[e],i=l[e===l.length-1?1:e+1],a=t.clone();if(w){p=Tx(t,i,f);const e=Mx(f,p),n=Sx(f,p),r=w*Math.min(4,1/n);a.x+=r*e.x,a.y+=r*e.y,a.x=Math.round(a.x),a.y=Math.round(a.y),f=p;}if(!m||0!==w&&!E||A(c,a)||c.push(a),hx(this.layoutVertexArray,a.x,a.y,0,0,1,1,0),this.wallMode){const t=x(e,l);dx(this.wallVertexArray,y.joinNormals[e],!t);}o.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),n.push(t.x,t.y),d&&px(this.layoutVertexExtArray,h.projectTilePoint(a.x,a.y,r),h.upVector(r,a.x,a.y));}m&&(0===w||E)&&(0!==c.length&&A(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u));}const l=this.wallMode?y.indices:Pl(n,a);for(let e=0;e<l.length;e+=3)this.footprintIndices.emplaceBack(s.vertexOffset+l[e+0],s.vertexOffset+l[e+1],s.vertexOffset+l[e+2]),this.indexArray.emplaceBack(i+l[e],i+l[e+2],i+l[e+1]),o.primitiveLength++;s.indexCount+=l.length,s.vertexCount+=this.footprintVertices.length-s.vertexOffset;}for(let n=0;n<e.length;n++){const a=e[n];p.startRing(_,a[0]);let s=a.length>4&&Fx(a[a.length-2],a[0],a[1]),l=w?zx(a[a.length-2],a[0],a[1],w):0;const c=[];let g,v,b;v=a[1].sub(a[0])._perp()._unit();let E=!0;for(let e=1,n=0;e<a.length;e++){let u=a[e-1],f=a[e];const I=a[e===a.length-1?1:e+1];if(p.appendEdge(_,f,u),Px(f,u,t)){w&&(v=I.sub(f)._perp()._unit(),E=!E);continue}const T=f.sub(u)._perp(),M=T.x/(Math.abs(T.x)+Math.abs(T.y)),S=T.y>0?1:0,z=u.dist(f);if(n+z>32768&&(n=0),w){b=Tx(f,I,v);let e=Rx(u,f,I,Sx(v,b),w);isNaN(e)&&(e=0);const t=Ix(u,f,new Pe(0,0));u=u.add(t.mult(l))._round(),f=f.add(t.mult(-e))._round(),l=e,v=b,m&&this.zoom>=17&&(A(c,u)||c.push(u),A(c,f)||c.push(f));}const R=o.vertexLength,P=a.length>4&&Fx(u,f,I);let D=Ox(n,s,E);if(hx(this.layoutVertexArray,u.x,u.y,M,S,0,0,D),hx(this.layoutVertexArray,u.x,u.y,M,S,0,1,D),this.wallMode){const t=x(e-1,a),i=y.joinNormals[e-1];dx(this.wallVertexArray,i,t),dx(this.wallVertexArray,i,t);}if(n+=z,D=Ox(n,P,!E),s=P,hx(this.layoutVertexArray,f.x,f.y,M,S,0,0,D),hx(this.layoutVertexArray,f.x,f.y,M,S,0,1,D),this.wallMode){const t=x(e,a),i=y.joinNormals[e];dx(this.wallVertexArray,i,t),dx(this.wallVertexArray,i,t);}if(o.vertexLength+=4,this.indexArray.emplaceBack(R+0,R+1,R+2),this.indexArray.emplaceBack(R+1,R+3,R+2),o.primitiveLength+=2,w){const n=i+(1===e?a.length-2:e-2),r=1===e?i:n+1;if(this.indexArray.emplaceBack(R+1,n,R+3),this.indexArray.emplaceBack(n,r,R+3),o.primitiveLength+=2,void 0===g&&(g=R),!Px(I,a[e],t)){const t=e===a.length-1?g:o.vertexLength;this.indexArray.emplaceBack(R+2,R+3,t),this.indexArray.emplaceBack(R+3,t+1,t),this.indexArray.emplaceBack(R+3,r,t+1),o.primitiveLength+=3;}E=!E;}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(u.x,u.y,r),i=h.projectTilePoint(f.x,f.y,r),n=h.upVector(r,u.x,u.y),o=h.upVector(r,f.x,f.y);px(e,t,n),px(e,t,n),px(e,i,o),px(e,i,o);}}f&&(i+=a.length-1),m&&w&&this.zoom>=17&&(0!==c.length&&A(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u,w>0));}this.footprintSegments.push(s),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++_.footprintSegLen,++_.polygonSegLen;}if(_.vertexCount=this.layoutVertexArray.length-_.vertexArrayOffset,_.groundVertexCount=this.groundEffect.vertexArray.length-_.groundVertexArrayOffset,0!==_.vertexCount){if(_.centroidXY=p.borders?lx:this.encodeCentroid(p,_),t.properties&&Object.hasOwn(t.properties,"building_id")){const e=_.buildingId;let t=this.buildingGroups.get(e);t||(t={accX:0,accY:0,accCount:0,mergedMin:new Pe(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Pe(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(e,t)),t.accX+=p.acc.x,t.accY+=p.acc.y,t.accCount+=p.accCount,t.mergedMin.x=Math.min(t.mergedMin.x,_.min.x),t.mergedMin.y=Math.min(t.mergedMin.y,_.min.y),t.mergedMax.x=Math.max(t.mergedMax.x,_.max.x),t.mergedMax.y=Math.max(t.mergedMax.y,_.max.y),t.partIndices.push(this.centroidData.length);}if(this.centroidData.push(_),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;t<p.borders.length;t++)p.borders[t][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[t].push(e);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,o,a,r,l,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,n,o,a,r,l,this.worldview),this.maxHeight=Math.max(this.maxHeight,g);}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(0===e.partIndices.length)continue;const t=new xx;t.acc=new Pe(e.accX,e.accY),t.accCount=e.accCount;const i=new gx;i.min=e.mergedMin,i.max=e.mergedMax;const n=this.encodeCentroid(t,i),r=t.centroid();for(const t of e.partIndices){const i=this.centroidData.get(t);i.centroidXY.x===lx.x&&i.centroidXY.y===lx.y||(i.centroidXY=n),i.min=e.mergedMin,i.max=e.mergedMax,i.groupCentroidPos=r;}}this.buildingGroups.clear();}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]);}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const i=this.centroidData.get(t),n=+(i.min.y+i.max.y>Sr),r=2*n+(+(i.min.x+i.max.x>Sr)^n);for(let n=0;n<i.polygonSegLen;n++){const o=i.polygonSegIdx+n;e.push({centroidIdx:t,subtile:r,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx});}}const t=new uc;e.sort((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let i=0,n=0,r=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;r++;}const o=e.length;for(;n!==e.length;){i=e[n].triangleSegmentIdx;let a=0,s=n,l=n;for(let t=s;t<r&&e[t].subtile===a;t++)l++;for(;s!==r;){const n=e[s];a=n.subtile;const o=this.centroidData.get(n.centroidIdx).min.clone(),u=this.centroidData.get(n.centroidIdx).max.clone(),c={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let i=s;i<l;i++){const n=e[i],r=this.polygonSegments[n.polygonSegmentIdx],a=this.centroidData.get(n.centroidIdx).min,s=this.centroidData.get(n.centroidIdx).max,l=this.indexArray.uint16;for(let e=r.triangleArrayOffset;e<r.triangleArrayOffset+r.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);c.primitiveLength+=r.triangleCount,o.x=Math.min(o.x,a.x),o.y=Math.min(o.y,a.y),u.x=Math.max(u.x,s.x),u.y=Math.max(u.y,s.y);}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),s=l;for(let t=s;t<r&&e[t].subtile===e[s].subtile;t++)l++;}n=r;for(let t=n;t<o&&e[t].triangleSegmentIdx===e[n].triangleSegmentIdx;t++)r++;}t._trim(),this.indexArray=t;}getVisibleSegments(e,t,i){const n=new Uc;if(this.wallMode){for(const e of this.triangleSubSegments)n.segments.push(e.segment);return n}let r=0,o=0;const a=1<<e.canonical.z;if(t){const i=t.getMinMaxForTile(e);i&&(r=i.min,o=i.max);}o+=this.maxHeight;const s=e.toUnwrapped();let l;const u=[s.canonical.x/a+s.wrap,s.canonical.y/a],c=[(s.canonical.x+1)/a+s.wrap,(s.canonical.y+1)/a],h=(e,t,i)=>[dn(e[0],t[0],i[0]),dn(e[1],t[1],i[1])],d=[],f=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Sr,d[1]=e.min.y/Sr,f[0]=e.max.x/Sr,f[1]=e.max.y/Sr;const t=h(u,c,d),a=h(u,c,f);if(0===new zf([t[0],t[1],r],[a[0],a[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const s=e.segment;l&&l.vertexOffset!==s.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=s.vertexLength,l.primitiveLength+=s.primitiveLength):l={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(e,t){const i=e.centroid(),n=t.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(6,Math.round(n.y*this.tileToMeter/10));return new Pe(tt(i.x,1,8191)<<3|r,tt(i.y,1,8191)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Pe(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Pe(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Pe((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData.get(e.centroidDataIndex);if(t.flags&=ux,0!==t.groupCentroidPos.x||0!==t.groupCentroidPos.y){const e=t.span(),i=Math.min(7,Math.round(e.x*this.tileToMeter/10)),n=Math.min(6,Math.round(e.y*this.tileToMeter/10));t.centroidXY=new Pe(tt(t.groupCentroidPos.x,1,8191)<<3|i,tt(t.groupCentroidPos.y,1,8191)<<3|n);}else t.centroidXY=new Pe(0,0);this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,n=-1073741824&e.flags?lx:e.centroidXY,r=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||r!==n.x){for(let e=t;e<i;++e)this.centroidVertexArray.emplace(e,n.x,n.y);this.needsCentroidUpdate=!0;}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e);}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(Lp(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=1073741823;const r=[];for(const t of this.activeReplacements){if(t.order<i)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));if(t.footprint.buildingIds)for(const e of this.centroidData)e.flags&ux||e.flags&cx||t.min.x>e.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=t.clipMask!==ex.None?-1073741824:ux);else for(const i of this.centroidData)if(!(i.flags&ux||i.flags&cx||t.min.x>i.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;o<i.footprintSegLen;o++){const a=this.footprintSegments.get(i.footprintSegIdx+o);if(r.length=0,Nx(this.footprintVertices,a.vertexOffset,a.vertexCount,t.footprintTileId.canonical,e.canonical,r),Vp(t.footprint,r,this.footprintIndices.uint16,a.indexOffset,a.indexCount,-a.vertexOffset,-n)){i.flags|=t.clipMask!==ex.None?-1073741824:ux;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1];}footprintContainsPoint(e,t,i){let n=!1;for(let r=0;r<i.footprintSegLen;r++){const o=this.footprintSegments.get(i.footprintSegIdx+r);let a=0;for(const i of o.ringIndices){for(let r=a,s=i+a-1;r<i+a;s=r++){const i=this.footprintVertices.int16[2*(r+o.vertexOffset)+0],a=this.footprintVertices.int16[2*(r+o.vertexOffset)+1],l=this.footprintVertices.int16[2*(s+o.vertexOffset)+1];a>t!=l>t&&e<(this.footprintVertices.int16[2*(s+o.vertexOffset)+0]-i)*(t-a)/(l-a)+i&&(n=!n);}a=i;}}return n}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Sr)*Sr+(t+Sr);if(Object.hasOwn(this.partLookup,r)){const e=this.partLookup[r];return e?{height:e.height,hidden:!!(e.flags&ux)}:void 0}const o=this.centroidData.buffer,a=this.centroidData.length;for(let s=0;s<a;s++){const a=15*s;if(e>o[a+4]||o[a+2]>e||t>o[a+5]||o[a+3]>t)continue;const l=o[a+13];if(l<=i)continue;const u=this.centroidData.get(s);this.footprintContainsPoint(e,t,u)&&(i=l,this.partLookup[r]=u,n=!!(u.flags&ux));}if(i!==Number.NEGATIVE_INFINITY)return {height:i,hidden:n};this.partLookup[r]=void 0;}}function Ix(e,t,i){return e.equals(t)?i:t.sub(e)._unit()}function Tx(e,t,i){return e.equals(t)?i:t.sub(e)._perp()._unit()}function Mx(e,t){const i=e.add(t),n=i.mag();return 0===n?e:i.div(n)}function Sx(e,t){const i=Mx(e,t);return e.x*i.x+e.y*i.y}function zx(e,t,i,n){let r,o;return e.equals(t)?(o=Tx(t,i,new Pe(0,0)),r=o):(r=t.sub(e)._perp()._unit(),o=Tx(t,i,r)),Rx(e,t,i,Sx(r,o),n)}function Rx(e,t,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(i)/3,r*o/n)}function Px(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function Dx(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function Cx(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=Sr)||e.every(e=>e.y<=0)||e.every(e=>e.y>=Sr)}function Fx(e,t,i){if(e.x<0||e.x>=Sr||t.x<0||t.x>=Sr||i.x<0||i.x>=Sr)return !1;const n=i.sub(t),r=n.perp(),o=e.sub(t);return (n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y<0}function Ox(e,t,i){const n=t?2|e:-3&e;return i?1|n:-2&n}function Lx(){const e=Math.PI/32,t=Math.tan(e),i=fu;return i*Math.sqrt(1+2*t*t)-i}function Bx(e,t,i){const n=1<<i.z,r=fr(i.x/n),o=fr((i.x+1)/n),a=pr(i.y/n),s=pr((i.y+1)/n);return function(e,t,i,n,r=0,o){const a=[];if(!e.length||!i||!n)return a;const s=(e,t)=>{for(const i of e)a.push({polygon:i,bounds:t});},l=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let e=0;e<Math.abs(c);e++)h.push(c>0?0:1);for(let e=0;e<Math.min(l,u);e++)h.push(0),h.push(1);let d=e;if(d=Qy(d,t[0].y-r,t[1].y+r,1),d=Qy(d,t[0].x-r,t[1].x+r,0),!d.length)return a;const f=[];for(h.length?f.push({polygons:d,bounds:t,depth:0}):s(d,t);f.length;){const e=f.pop(),t=e.depth,i=h[t],n=e.bounds[0],a=e.bounds[1],l=0===i?n.x:n.y,u=0===i?a.x:a.y,c=o?o(i,l,u):.5*(l+u),d=Qy(e.polygons,l-r,c+r,i),p=Qy(e.polygons,c-r,u+r,i);if(d.length){const e=[n,new Pe(0===i?c:a.x,1===i?c:a.y)];h.length>t+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e);}if(p.length){const e=[new Pe(0===i?c:n.x,1===i?c:n.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e);}}return a}(e,t,Math.ceil((o-r)/11.25),Math.ceil((a-s)/11.25),1,(e,t,r)=>{if(0===e)return .5*(t+r);{const e=pr((i.y+t/Sr)/n);return (dr(.5*(pr((i.y+r/Sr)/n)+e))*n-i.y)*Sr}})}function Nx(e,t,i,n,r,o){const a=Math.pow(2,n.z-r.z);for(let s=0;s<i;s++){let i=e.int16[2*(s+t)+0],l=e.int16[2*(s+t)+1];i=(i+r.x*Sr)*a-n.x*Sr,l=(l+r.y*Sr)*a-n.y*Sr,o.push(new Pe(i,l));}}qa(Ax,"FillExtrusionBucket",{omit:["layers","features"]}),qa(gx,"PartData"),qa(yx,"PartDataArray"),qa(mx,"FootprintSegmentArray"),qa(xx,"BorderCentroidData"),qa(Ex,"GroundEffect");const Vx=4096;class kx{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Vx),this.memoryStackNextFree=this.memoryStack;}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Vx?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Vx?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters);}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t);}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t);}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0);}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0);}setFauxFacadeOptions(e,t,i){this.module.setFauxFacadeOptions(e?1:0,t?1:0,i);}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e);}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),i=this.createFloatArray(t.coordinates);if(-1===e||-1===i)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,i,e,t.ringIndices.length-1);}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const i=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===i||-1===n)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,i,t.length,n,e.coordinates.length);}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const i=this.module.getMeshCount(),n=new Array(i);for(let e=0;e<i;e++){const t=this.module.getPositionsPtr(e),i=this.module.getPositionsLength(e),r=new Float32Array(this.module.heapF32.buffer,t,i),o=this.module.getNormalsPtr(e),a=this.module.getNormalsLength(e),s=new Float32Array(this.module.heapF32.buffer,o,a),l=this.module.getAOPtr(e),u=this.module.getAOLength(e),c=new Float32Array(this.module.heapF32.buffer,l,u),h=this.module.getUVPtr(e),d=this.module.getUVLength(e),f=new Float32Array(this.module.heapF32.buffer,h,d),p=this.module.getFauxFacadePtr(e),_=this.module.getFauxFacadeLength(e),m=new Uint8Array(this.module.heapU8.buffer,p,_),g=this.module.getIndicesPtr(e),y=this.module.getIndicesLength(e),x=new Int16Array(this.module.heap16.buffer,g,y),v=this.module.getBuildingPart(e);n[e]={positions:r,normals:s,ao:c,uv:f,isFauxFacade:m,indices:x,buildingPart:v};}const r=this.module.getRingCount(),o=[];for(let e=0;e<r;e++){const t=this.module.getRingPtr(e),i=this.module.getRingLength(e),n=new Float32Array(this.module.heapF32.buffer,t,i);o.push(n);}return {meshes:n,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:o}}}const Ux=Ph.types,Gx=32767;function jx(e,t){const i=Sr+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return !1;return !0}function Hx(e){switch(e){case "flat":return 3;case "hipped":return 1;case "gabled":return 2;case "parapet":return 0;case "mansard":return 4;case "skillion":return 5;case "pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}let $x,Zx,Wx=null,qx=null,Xx=null;class Yx{constructor(){this.layoutVertexArray=new Yu,this.layoutAttenuationArray=new ic,this.layoutColorArray=new rc,this.indexArray=new uc,this.indexArrayForConflation=new uc,this.segmentsBucket=new Uc;}}class Jx{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Uc,this.entranceBloom=new Yx;const t=66560;this.layoutVertexArray=new Yu,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Gu,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Gu,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new rc,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new wc,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new Ec,this.layoutAOArray.reserve(t),this.indexArray=new uc,this.indexArray.reserve(66560),this.indexArrayForConflation=new uc,this.segmentsBucket=new Uc,this.entranceBloom=new Yx,e&&(this.layoutFacadePaintArray=new rc,this.layoutFacadeDataArray=new Ku,this.layoutFacadeVerticalRangeArray=new rc);}reserve(e,t,i){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),i&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e));}}class Kx{constructor(e){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new gc,this.footprintsIndices=new xc,this.footprintsMin=new Pe(1/0,1/0),this.footprintsMax=new Pe(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Jx(!1),this.buildingWithFacade=new Jx(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new ph(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new Ex(e),this.groundEffect.groundRadiusArray=new Hu,this.hasAppearances=null;}updateFootprints(e,t){const i=new jg([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:i,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e});}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){if(!Xx)return;const r=Au(i);this.tileToMeter=r,this.brightness=t.brightness,Xx.setStyle({normalScale:[1,-1,r],tileToMeters:r}),Xx.setAOOptions(!1,.3),Xx.setMetricOptions(!1,16),Xx.setStructuralOptions(!0),Xx.setFacadeClassifierOptions(3);const o=new Map,a=new Map;let s=0;for(const{feature:t}of e){if("LineString"!==Ux[t.type]){o.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Hs(this.zoom),t,i))continue;const r=Fu(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new Hs(this.zoom),r,i))continue;const l=e?r.geometry:Cu(t,i,n),u=[];for(const e of l)for(const t of e)u.push(t.x),u.push(t.y);const c={coordinates:u,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=a.get(h);d||(d=[],a.set(h,d)),d.push(c),++s;}this.maxHeight=0;const l=new Array,u=new Set,c=e=>{null!=e&&u.add(e);},h=(e,t)=>{null!=e&&l.push({buildingId:e,footprintIndex:t});},d=64*(e.length-s),f=d/2;this.buildingWithFacade.reserve(d,f,!0),this.buildingWithoutFacade.reserve(2*d,2*f,!1),this.footprintsIndices.reserve(16*(e.length-s)),this.footprintsVertices.reserve(8*(e.length-s));for(const{feature:s,id:l,index:d,sourceLayerIndex:f}of e){if("LineString"===Ux[s.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Hs(this.zoom),s,i))continue;let p=null;if(s.properties&&Object.hasOwn(s.properties,"building_id")&&(p=Number(s.properties.building_id),u.has(p)))continue;const _=Fu(s,e);if(!e&&!this.layers[0]._featureFilter.filter(new Hs(this.zoom),_,i))continue;const m=e?_.geometry:Cu(s,i,n),g=Ne(m,500);let y=!1;for(const e of g)if(1!==e.length){y=!0;break}if(y){c(p);continue}if(!jx(m,163)){c(p);continue}const x=this.layers[0],v=Hx(x.layout.get("building-roof-shape").evaluate(s,{},i)),b=x.layout.get("building-base").evaluate(s,{},i),w=x.layout.get("building-height").evaluate(s,{},i),E=x.layout.get("building-flood-light-ground-radius").evaluate(s,{},i),A=x.paint.get("building-ambient-occlusion-intensity"),I=E/this.tileToMeter;s.properties["building-part"]="roof";const T=x.paint.get("building-color").evaluate(s,{},this.canonical).toPremultipliedRenderColor(this.lut),M=x.paint.get("building-emissive-strength").evaluate(s,{},this.canonical);s.properties["building-part"]="wall";const S=x.paint.get("building-color").evaluate(s,{},this.canonical).toPremultipliedRenderColor(this.lut),z=x.paint.get("building-emissive-strength").evaluate(s,{},this.canonical);s.properties["building-part"]="window";const R=x.paint.get("building-color").evaluate(s,{},this.canonical).toPremultipliedRenderColor(this.lut),P=x.paint.get("building-emissive-strength").evaluate(s,{},this.canonical);s.properties["building-part"]="door";const D=x.paint.get("building-color").evaluate(s,{},this.canonical).toPremultipliedRenderColor(this.lut),C=x.paint.get("building-emissive-strength").evaluate(s,{},this.canonical);let F=x.layout.get("building-flood-light-wall-radius").evaluate(s,{},i);F=tt(F,0,2048);const O=F/2048*Gx,L=o.get(l),B=a.get(L)||[],N=0!==B.length&&x.layout.get("building-facade").evaluate(s,{},i);Xx.setFacadeOptions(4,!0),Xx.setFauxFacadeOptions(N,!1,1);let V=0,k=0,U=0,G=0,j=0,H=0,$=0,Z=0,W=0,q=0,X=0;if(N){let e=Math.round(x.layout.get("building-facade-floors").evaluate(s,{},i));if(0===b){e=Math.max(1,e-(B.length>0?1:0));let t=4;if(w>100){const e=[10,13,15];t=e[s.id?s.id%e.length:0];}else w<=10&&(t=3);Xx.setFacadeOptions(t,!0),j=(w<15?1.3:1.61803)*t/r;}else j=b/r;H=w/r,j=Math.min(j,H),U=x.layout.get("building-facade-unit-width").evaluate(s,{},i)/r,G=(H-j)/e,Xx.setFauxFacadeOptions(!0,!0,U);const t=x.layout.get("building-facade-window").evaluate(s,{},i);V=t[0],k=t[1],$=Math.floor(65535*Math.min(1,j/Sr)),Z=Math.floor(65535*Math.min(1,H/Sr)),W=Math.floor(255*V)<<8|Math.floor(255*k),q=Math.floor(65535*Math.min(1,U/Sr)),X=Math.floor(65535*Math.min(1,G/Sr));}const Y=Array(g.length),J={x:1/0,y:1/0},K={x:-1/0,y:-1/0},Q={x:0,y:0};let ee=0;for(let e=0;e<g.length;e++){const t=g[e];if(t.length>0){const i=[],n=Array(t.length+1);n[0]=0;for(let e=0;e<t.length;e++){const r=t[e];for(let e=0;e<r.length;e++){const t=r[r.length-e-1];J.x=Math.min(J.x,t.x),J.y=Math.min(J.y,t.y),K.x=Math.max(K.x,t.x),K.y=Math.max(K.y,t.y),Q.x+=t.x,Q.y+=t.y,ee++,i.push(t.x),i.push(t.y);}n[e+1]=i.length;}Y[e]={id:s.id?s.id:0,height:w,minHeight:b,sourceId:0,roofType:v,coordinates:i,ringIndices:n};}}Q.x/=ee||1,Q.y/=ee||1;const te=Xx.generateMesh(Y,B);if("string"==typeof te){mt(`Unable to generate building ${s.id}: ${te}`),c(p);continue}if(0===te.meshes.length||0===te.modifiedPolygonRings.length){c(p);continue}const ie=N?this.buildingWithFacade:this.buildingWithoutFacade;let ne=0;for(const e of te.meshes)ne+=e.positions.length/3;const re=ie.segmentsBucket.prepareSegment(ne,ie.layoutVertexArray,ie.indexArray),oe=[];let ae=null,se=0,le=-1;const ue=ie.layoutVertexArray.length,ce=ue+ne;ie.layoutVertexArray.resize(ce),ie.layoutCentroidArray.resize(ce),ie.layoutNormalArray.resize(ce),ie.layoutAOArray.resize(ce),ie.layoutColorArray.resize(ce),ie.layoutFloodLightDataArray.resize(ce),N&&(ie.layoutFacadePaintArray.resize(ce),ie.layoutFacadeDataArray.resize(ce),ie.layoutFacadeVerticalRangeArray.resize(ce));const he=ie.indexArray.length;let de=0,fe=ue;for(const e of te.meshes){let t,i;if(1===e.buildingPart)t=T,i=M;else if(0===e.buildingPart)t=S,i=z;else if(2===e.buildingPart)t=R,i=P;else {if(3!==e.buildingPart)continue;t=D,i=C;}if(i=tt(i,0,1),3===e.buildingPart){const t=new Array;for(let i=0;i<e.positions.length;i+=12){const n=e.positions[i+0],r=e.positions[i+1],o=e.positions[i+3],a=e.positions[i+4],s=e.positions[i+2],l=e.positions[i+8]-s,u=1,c=o-n,h=a-r,d=Math.hypot(c,h);t.push({pos:[n+.5*c,r+.5*h,s],normal:[h/d,-c/d,0],width:d,height:l,depth:u,points:[n,r,o,a]});}const i=ie.entranceBloom.segmentsBucket.prepareSegment(10*t.length,ie.entranceBloom.layoutVertexArray,ie.entranceBloom.indexArray),n=ie.entranceBloom.layoutVertexArray.length;se=ie.entranceBloom.indexArray.length,Fy(t,.5/this.tileToMeter,ie.entranceBloom.indexArray,ie.entranceBloom.layoutVertexArray,ie.entranceBloom.layoutAttenuationArray);const r=ie.entranceBloom.layoutVertexArray.length-n;le=ie.entranceBloom.indexArray.length-se;for(let e=0;e<r;e++)ie.entranceBloom.layoutColorArray.emplaceBack(255*D.r<<8|255*D.g,255*D.b<<8|51*C);i.vertexLength+=r,i.primitiveLength+=le,ae={part:e.buildingPart,vertexOffset:n,vertexLength:r};}ie.layoutVertexArray.float32.set(e.positions,3*fe);const n=e.positions.length/3;for(let r=0;r<n;++r){const n=3*r;de=Math.max(de,e.positions[n+2]);const o=e.normals[n+1]*Gx,a=e.normals[n+2]*Gx,s=3*(fe+r);ie.layoutNormalArray.int16[s]=e.normals[n]*Gx,ie.layoutNormalArray.int16[s+1]=o,ie.layoutNormalArray.int16[s+2]=a;const l=e.ao[r];ie.layoutAOArray.uint8[fe+r]=255*l;const u=1+(l-1)*A,c=255*t.b*u<<8|255*i;ie.layoutColorArray.uint16[2*(fe+r)]=255*t.r*u<<8|255*t.g*u,ie.layoutColorArray.uint16[2*(fe+r)+1]=c;}const r=Math.min(8191,Math.max(0,Math.floor(Q.x))),o=Math.min(8191,Math.max(0,Math.floor(Q.y))),a=Math.floor(w),s=20,l=4*r+Math.min(3,Math.round((K.x-J.x)*this.tileToMeter/s)),u=4*o+Math.min(3,Math.round((K.y-J.y)*this.tileToMeter/s));for(let e=0;e<n;++e){const t=3*(fe+e);ie.layoutCentroidArray.int16[t]=l,ie.layoutCentroidArray.int16[t+1]=u,ie.layoutCentroidArray.int16[t+2]=a;}if(ie.layoutFloodLightDataArray.int16.fill(0===e.buildingPart?O:0,fe,fe+n),N){const t=255*R.r<<8|255*R.g,i=255*R.b<<8|255*P;for(let e=0;e<n;++e){const n=2*(fe+e);ie.layoutFacadePaintArray.uint16[n]=t,ie.layoutFacadePaintArray.uint16[n+1]=i;}for(let t=0;t<n;++t)if(e.isFauxFacade[t]){const i=Math.min(65535,Math.floor(e.uv[2*t]*te.outerRingLength));ie.layoutFacadeDataArray.emplace(fe+t,1|i,W,q,X),ie.layoutFacadeVerticalRangeArray.emplace(fe+t,$,Z);}else ie.layoutFacadeDataArray.emplace(fe+t,0,0,0,0),ie.layoutFacadeVerticalRangeArray.emplace(fe+t,0,0);}const c=re.vertexLength,h=e.indices.length/3,d=ie.indexArray.length;ie.indexArray.resize(d+h);for(let t=0;t<h;++t){const i=3*t,n=3*d+i;ie.indexArray.uint16[n]=c+e.indices[i],ie.indexArray.uint16[n+1]=c+e.indices[i+1],ie.indexArray.uint16[n+2]=c+e.indices[i+2];}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||oe.push({part:e.buildingPart,vertexOffset:fe,vertexLength:e.positions.length/3}),fe+=n,re.vertexLength+=n,re.primitiveLength+=e.indices.length/3;}this.maxHeight=Math.max(this.maxHeight,de);const pe=ie.indexArray.length-he,_e=this.footprintsIndices.length,me=this.footprintsVertices.length,ge=[],ye=new Pe(1/0,1/0),xe=new Pe(-1/0,-1/0),ve=b<=0,be=this.groundEffect.vertexArray.length;for(const e of te.modifiedPolygonRings){const t=[],i=new Pe(1/0,1/0),n=new Pe(-1/0,-1/0);for(let r=0;r<e.length;r+=2){const o=e.length-r-2;i.x=Math.min(i.x,e[o]),i.y=Math.min(i.y,e[o+1]),n.x=Math.max(n.x,e[o]),n.y=Math.max(n.y,e[o+1]);const a=new Pe(e[o],e[o+1]);ve&&t.push(a),ge.push(a.x,a.y),this.footprintsVertices.emplaceBack(a.x,a.y);}ye.x=Math.min(ye.x,i.x),ye.y=Math.min(ye.y,i.y),xe.x=Math.max(xe.x,n.x),xe.y=Math.max(xe.y,n.y),ve&&this.groundEffect.addData(t,[i,n],I);}const we=this.groundEffect.vertexArray.length-be;this.groundEffect.groundRadiusArray.reserveForAdditional(we);for(let e=0;e<we;e++)this.groundEffect.groundRadiusArray.emplaceBack(E);(J.x<0||K.x>Sr||J.y<0||K.y>Sr)&&this.featuresOnBorder.push({featureId:s.id,footprintIndex:this.footprints.length});{const e=Pl(ge,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,_e),this.buildingIds.add(p??s.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,ye.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,ye.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,xe.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,xe.y);const t={footprintVertexOffset:me,footprintVertexLength:this.footprintsVertices.length-me,footprintIndexOffset:_e,footprintIndexLength:this.footprintsIndices.length-_e,min:ye,max:xe,hiddenFlags:0,indicesOffset:he,indicesLength:pe,bloomIndicesOffset:se,bloomIndicesLength:le,groundEffectVertexOffset:be,groundEffectVertexLength:we,hasFauxFacade:N,height:de,promoteId:l,feature:_,parts:oe,buildingBloom:ae},i=this.footprints.length;void 0!==s.id&&this.featureFootprintLookup.set(s.id,i),h(p,i),this.footprints.push(t);}this.programConfigurations.populatePaintArrays(ie.layoutVertexArray.length,s,d,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(s,d,{},t.availableImages,i,t.brightness),t.featureIndex.insert(s,m,d,f,this.index,ue);}l.forEach(({buildingId:e,footprintIndex:t})=>{u.has(e)&&(this.footprints[t].hiddenFlags|=4);});const p=new Set;this.buildingIds.forEach((e,t,i)=>{u.has(e)||p.add(e);}),this.buildingIds=p,this.groundEffect.prepareBorderSegments();}update(e,t,i,n,r,o,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,a),this.groundEffect.update(e,t,r,i,n,o,a),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1;}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,Ly.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,By.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,Ny.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,Hy.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,Uy.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Gy.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,Ly.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,jy.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e);};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()));};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy();}updateFootprintHiddenFlags(e,t,i=!0){let n=!1;const r=i?t:0,o=0|(i?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],i=e.hiddenFlags&o|r;e.hiddenFlags!==i&&(e.hiddenFlags=i,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags));}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16));};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,i=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n<i;n++)t.indexArrayForConflation.uint16[3*n+0]=0,t.indexArrayForConflation.uint16[3*n+1]=0,t.indexArrayForConflation.uint16[3*n+2]=0;const n=e.bloomIndicesOffset+e.bloomIndicesLength;for(let i=e.bloomIndicesOffset;i<n;i++)t.entranceBloom.indexArrayForConflation.uint16[3*i+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+2]=0;}}const i=t=>{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0));};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0;}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,Vy.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,ky.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Vy.members,!0);};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0;}evaluate(e,t){const i=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const r=t[n.promoteId],o=n.feature;o.properties["building-part"]="roof";const a=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),s=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="window";const c=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),f=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical),p=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,r=a;1===e.part?(r=a,t=s):0===e.part?(r=l,t=u):2===e.part?(r=c,t=h):3===e.part&&(r=d,t=f),t=tt(t,0,1);for(let o=0;o<e.vertexLength;o++){const a=e.vertexOffset+o,s=1+(p.layoutAOArray.uint8[a]/255-1)*i;p.layoutColorArray.emplace(a,r.r*s*255<<8|r.g*s*255,r.b*s*255<<8|255*t),n.hasFauxFacade&&p.layoutFacadePaintArray.emplace(a,255*c.r<<8|255*c.g,255*c.b<<8|255*h);}}const _=n.buildingBloom;if(_)for(let e=0;e<_.vertexLength;e++)p.entranceBloom.layoutColorArray.emplace(_.vertexOffset+e,255*d.r<<8|255*d.g,255*d.b<<8|51*f);}}needsEvaluation(){return !this.colorBufferUploaded}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(Lp(this.activeReplacements,n))return;this.activeReplacements=n;for(const e of this.footprints)e.hiddenFlags&=-2;const r=[];for(const t of this.activeReplacements){if(t.order<i)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));for(const i of this.footprints)i.min.x>t.max.x||i.max.x<t.min.x||i.min.y>t.max.y||i.max.y<t.min.y||(r.length=0,ev(this.footprintsVertices,i.footprintVertexOffset,i.footprintVertexLength,t.footprintTileId.canonical,e.canonical,r),Vp(t.footprint,r,this.footprintsIndices.uint16,i.footprintIndexOffset,i.footprintIndexLength,0,-n)&&(i.hiddenFlags|=1));}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags);this.indexArrayForConflationUploaded=!1;}getFootprint(e){if(void 0!==e.id){const t=this.featureFootprintLookup.get(e.id);return this.footprints[t]}return null}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Sr)*Sr+(t+Sr);if(Object.hasOwn(this.footprintLookup,r)){const e=this.footprintLookup[r];return e?{height:e.height,hidden:0!==e.hiddenFlags}:void 0}const o=new Pe(e,t);for(const a of this.footprints)e>a.max.x||a.min.x>e||t>a.max.y||a.min.y>t||a.height<=i||Qx(o,this.footprintsVertices.float32.subarray(2*a.footprintVertexOffset,2*(a.footprintVertexOffset+a.footprintVertexLength)),this.footprintsIndices.uint16.subarray(a.footprintIndexOffset,a.footprintIndexOffset+a.footprintIndexLength))&&(i=a.height,this.footprintLookup[r]=a,n=0!==a.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return {height:i,hidden:n};this.footprintLookup[r]=void 0;}}function Qx(e,t,i){for(let n=0;n<i.length;n+=3){const r=i[n],o=i[n+1],a=i[n+2],s=t[2*r+0],l=t[2*r+1],u=t[2*o+0],c=t[2*o+1],h=t[2*a+0],d=t[2*a+1],f=(s-h)*(e.y-d)-(l-d)*(e.x-h),p=(u-s)*(e.y-l)-(c-l)*(e.x-s);if(f<0!=p<0&&0!==f&&0!==p)continue;const _=(h-u)*(e.y-c)-(d-c)*(e.x-u);if(0===_||_<0==f+p<=0)return !0}return !1}function ev(e,t,i,n,r,o){const a=Math.pow(2,n.z-r.z);for(let s=0;s<i;s++){let i=e.float32[2*(s+t)+0],l=e.float32[2*(s+t)+1];i=(i+r.x*Sr)*a-n.x*Sr,l=(l+r.y*Sr)*a-n.y*Sr,o.push(new Pe(i,l));}}qa(Kx,"BuildingBucket",{omit:["layers"]}),qa(Jx,"BuildingGeometry"),qa(Yx,"BuildingBloomGeometry");class tv{constructor(e=0,t=[]){this.frcMask=e,this.rings=t;}hasGeometry(){return this.rings.length>0&&this.rings[0].length>0}}async function iv(){}function nv(e,t,i){const n=t.paint.get(e).value;return "constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function rv(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ov(e,t,i,n,r){if(!t[0]&&!t[1])return e;const o=Pe.convert(t)._mult(r);"viewport"===i&&o._rotate(-n);const a=[];for(let t=0;t<e.length;t++)a.push(e[t].sub(o));return a}function av(e,t,i,n){const r=Pe.convert(e)._mult(n);return "viewport"===t&&r._rotate(-i),r}qa(tv,"FrcCoveragePolygon");const sv=u(),lv=e=>{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function uv(e,t,i,n,r,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return !1;o&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=i.projection.upVectorScale(u,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,f=i.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=i.projection.upVector(u,h.x,h.y);f.x+=e[0]*c*d,f.y+=e[1]*c*d,f.z+=e[2]*c*d;}const p=o?h:cv(f.x,f.y,f.z,n),_=o?e.tilespaceRays.map(e=>fv(e,d)):e.queryGeometry.screenGeometry,m=le([],[f.x,f.y,f.z,1],n);if(!a&&o?l*=m[3]/i.cameraToCenterDistance:a&&!o&&(l*=i.cameraToCenterDistance/m[3]),o){const e=pr((t.y/Sr+u.y)/(1<<u.z));l/=i.projection.pixelsPerMeter(e,1)/yu(1,e);}if(Bh(_,p,l))return !0}return !1}function cv(e,t,i,n){const r=le([],[e,t,i,1],n);return new Pe(r[0]/r[3],r[1]/r[3])}const hv=C(0,0,0),dv=C(0,0,1);function fv(e,t){const i=R();return hv[2]=t,e.intersectsPlane(hv,dv,i),new Pe(i[0],i[1])}class pv extends wd{}let _v,mv;qa(pv,"HeatmapBucket",{omit:["layers"]});const gv=(e,t,i,n)=>dn(t,i,"log"===n?(Math.pow(10,e)-1)/9:e);function yv(e){const{expression:t,evaluationKey:i,resolution:n=256,clips:r,scale:o="linear",lut:a=null}=e,s=r?r.length:1,l=e.image||new ud({width:n,height:s}),u={},c=(e,n,r)=>{u[i]=r;const o=t.evaluate(u),s=o?.toNonPremultipliedRenderColor(a)??null;s&&(l.data[e+n+0]=Math.floor(255*s.r),l.data[e+n+1]=Math.floor(255*s.g),l.data[e+n+2]=Math.floor(255*s.b),l.data[e+n+3]=Math.floor(255*s.a));};for(let e=0,t=0;e<s;++e,t+=4*n){const i=r?.[e].start??0,a=r?.[e].end??1;for(let e=0,r=0;e<n;e++,r+=4)c(t,r,gv(e/(n-1),i,a,o));}return l}let xv,vv,bv,wv,Ev,Av,Iv,Tv,Mv,Sv,zv,Rv;class Pv{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e});}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){const r=[];for(const{feature:o,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Fu(o,e);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const c={id:a,properties:o.properties,type:o.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Cu(o,i,n),patterns:{}};r.push(c);}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:a}=n;this.addFeature(n,r,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,r,o,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(e){}update(e,t,i,n,r,o,a){}destroy(){}addFeature(e,t,i,n,r,o=[],a){for(const e of Ne(t,2)){const t=[],i=[],n=[],r=new Pe(1/0,1/0),o=new Pe(-1/0,-1/0);for(const a of e)if(0!==a.length){a!==e[0]&&n.push(i.length/2);for(let e=0;e<a.length;e++)i.push(a[e].x),i.push(a[e].y),t.push(a[e]),r.x=Math.min(r.x,a[e].x),r.y=Math.min(r.y,a[e].y),o.x=Math.max(o.x,a[e].x),o.y=Math.max(o.y,a[e].y);}const a=Pl(i,n),s=new jg(t,a,8,256);this.footprints.push({vertices:t,indices:a,grid:s,min:r,max:o});}}}function Dv(e,t){return e.x*t.x+e.y*t.y}function Cv(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i<t.length;i++){const o=t[i],a=e[0],s=r.sub(n),l=o.sub(n),u=a.sub(n),c=Dv(s,s),h=Dv(s,l),d=Dv(l,l),f=Dv(u,s),p=Dv(u,l),_=c*d-h*h,m=(d*f-h*p)/_,g=(c*p-h*f)/_,y=n.z*(1-m-g)+r.z*m+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}}function Fv(e,t,i){let n=1/0;Nh(i,t)&&(n=Cv(i,t[0]));for(let r=0;r<t.length;r++){const o=t[r],a=e[r];for(let e=0;e<o.length-1;e++){const t=o[e],r=[t,o[e+1],a[e+1],a[e],t];Lh(i,r)&&(n=Math.min(n,Cv(i,r)));}}return n!==1/0&&n}function Ov(e,t,i,n,r,o,a,s,l,u,c){return "globe"===e.projection.name?function(e,t,i,n,r,o,a,s,l,u,c){const h=[],d=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,p=[0,0,0,1],_=[0,0,0,1],m=(e,t,i,n)=>{e[0]=t,e[1]=i,e[2]=n,e[3]=1;},g=Lx();i>0&&(i+=g),n+=g;for(const g of t){const t=[],y=[];for(const h of g){const d=h.x+r.x,g=h.y+r.y,x=e.projection.projectTilePoint(d,g,c),v=e.projection.upVector(c,h.x,h.y);let b=i,w=n;if(a){const e=Lv(d,g,i,n,a,s,l,u);b+=e.base,w+=e.top;}0!==i?m(p,x.x+v[0]*f*b,x.y+v[1]*f*b,x.z+v[2]*f*b):m(p,x.x,x.y,x.z),m(_,x.x+v[0]*f*w,x.y+v[1]*f*w,x.z+v[2]*f*w),Y(p,p,o),Y(_,_,o),t.push(new Kh(p[0],p[1],p[2])),y.push(new Kh(_[0],_[1],_[2]));}h.push(t),d.push(y);}return [h,d]}(e,t,i,n,r,o,a,s,l,u,c):a?function(e,t,i,n,r,o,a,s,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],f=[];for(const u of d){const c=u.x+n.x,d=u.y+n.y,p=Lv(c,d,t,i,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,le(h,h,r),h[3]=Math.max(h[3],1e-5);const _=new Kh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=p.top,h[3]=1,le(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new Kh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(m);}u.push(e),c.push(f);}return [u,c]}(t,i,n,r,o,a,s,l,u):function(e,t,i,n,r){const o=[],a=[],s=r[8]*t,l=r[9]*t,u=r[10]*t,c=r[11]*t,h=r[8]*i,d=r[9]*i,f=r[10]*i,p=r[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+n.x,a=o.y+n.y,_=r[0]*t+r[4]*a+r[12],m=r[1]*t+r[5]*a+r[13],g=r[2]*t+r[6]*a+r[14],y=r[3]*t+r[7]*a+r[15],x=_+s,v=m+l,b=g+u,w=Math.max(y+c,1e-5),E=_+h,A=m+d,I=g+f,T=Math.max(y+p,1e-5);e.push(new Kh(x/w,v/w,b/w)),i.push(new Kh(E/T,A/T,I/T));}o.push(e),a.push(i);}return [o,a]}(t,i,n,r,o)}function Lv(e,t,i,n,r,o,a,s){const l=a*r.getElevationAt(e,t,!0,!0),u=0!==o[0],c=u?0===o[1]?a*(o[0]/7-450):a*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),o=10*(t[0]-8*n),a=10*(t[1]-8*r),s=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),u=Math.floor(.5*(o*l-1)),c=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(n,r),d=2*u+1,f=2*c+1,p=function(e,t,i,n,r){return [e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+r,i,!0),e.getElevationAtPixel(t,i+r,!0),e.getElevationAtPixel(t+n,i+r,!0)]}(e,h.x-u,h.y-c,d,f),_=Math.abs(p[0]-p[1]),m=Math.abs(p[2]-p[3]),g=Math.abs(p[0]-p[2])+Math.abs(p[1]-p[3]),y=Math.min(.25,.5*l*(_+m)/d),x=Math.min(.25,.5*l*g/f);return s+Math.max(y*o,x*a)}(r,o,s):l;return {base:l+(0===i?-1:i),top:u?Math.max(c+n,l+i+2):l+n}}function Bv(e,t,i){return t*(Sr/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function Nv(e,t){return 1/Bv(e,1,t.tileZoom)}function Vv(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}qa(Pv,"ClipBucket",{omit:["layers"]});const kv=e=>{const t=[];Uv(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT"),"multiply"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_MULTIPLY"),"additive"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_ADDITIVE");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET");const n=0!==e.paint.get("line-border-width").constantOr(1);n&&t.push("RENDER_LINE_BORDER"),n&&e.paint.get("line-border-gradient")&&t.push("RENDER_LINE_BORDER_GRADIENT");const r="none"===e.layout.get("line-join").constantOr("miter"),o=!!e.paint.get("line-pattern").constantOr(1);return r&&o&&t.push("LINE_JOIN_NONE"),t};function Uv(e){const t=e.paint.get("line-dasharray").value;return "constant"!==t.kind||t.value}let Gv;const jv=()=>Gv||(Gv={layout:zv||(zv=new il({"line-cap":new el(nl.layout_line["line-cap"]),"line-join":new el(nl.layout_line["line-join"]),"line-miter-limit":new Qs(nl.layout_line["line-miter-limit"]),"line-round-limit":new Qs(nl.layout_line["line-round-limit"]),"line-sort-key":new el(nl.layout_line["line-sort-key"]),"line-z-offset":new el(nl.layout_line["line-z-offset"]),"line-elevation-reference":new Qs(nl.layout_line["line-elevation-reference"]),"line-cross-slope":new Qs(nl.layout_line["line-cross-slope"]),visibility:new Qs(nl.layout_line.visibility),"line-width-unit":new Qs(nl.layout_line["line-width-unit"]),"line-elevation-ground-scale":new el(nl.layout_line["line-elevation-ground-scale"])})),paint:Rv||(Rv=new il({"line-opacity":new el(nl.paint_line["line-opacity"]),"line-color":new el(nl.paint_line["line-color"]),"line-translate":new Qs(nl.paint_line["line-translate"]),"line-translate-anchor":new Qs(nl.paint_line["line-translate-anchor"]),"line-width":new el(nl.paint_line["line-width"]),"line-gap-width":new el(nl.paint_line["line-gap-width"]),"line-offset":new el(nl.paint_line["line-offset"]),"line-blur":new el(nl.paint_line["line-blur"]),"line-dasharray":new el(nl.paint_line["line-dasharray"]),"line-pattern":new el(nl.paint_line["line-pattern"]),"line-pattern-cross-fade":new Qs(nl.paint_line["line-pattern-cross-fade"]),"line-gradient":new tl(nl.paint_line["line-gradient"]),"line-trim-offset":new Qs(nl.paint_line["line-trim-offset"]),"line-trim-fade-range":new Qs(nl.paint_line["line-trim-fade-range"]),"line-trim-color":new Qs(nl.paint_line["line-trim-color"]),"line-emissive-strength":new el(nl.paint_line["line-emissive-strength"]),"line-border-width":new el(nl.paint_line["line-border-width"]),"line-border-color":new el(nl.paint_line["line-border-color"]),"line-border-gradient":new tl(nl.paint_line["line-border-gradient"]),"line-occlusion-opacity":new Qs(nl.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Qs(nl.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new Qs(nl.paint_line["line-blend-additive-clamp"]),"line-cutout-depth":new Qs(nl.paint_line["line-cutout-depth"]),"line-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"line-border-gradient-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},Gv);class Hv extends el{possiblyEvaluate(e,t){return t=new Hs(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t={...t,zoom:Math.floor(t.zoom)},super.evaluate(e,t,i,n)}}let $v,Zv,Wv,qv;function Xv(e,t){return t>0?t+2*e:e}function Yv(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>i in e?String(e[i]):"")}class Jv{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:wn,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&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}}qa(Jv,"FormatSectionOverride",{omit:["defaultValue"]});const Kv=()=>qv||(qv={layout:Zv||(Zv=new il({"symbol-placement":new Qs(nl.layout_symbol["symbol-placement"]),"symbol-spacing":new Qs(nl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Qs(nl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new el(nl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Qs(nl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Qs(nl.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Qs(nl.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Qs(nl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Qs(nl.layout_symbol["icon-ignore-placement"]),"icon-optional":new Qs(nl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Qs(nl.layout_symbol["icon-rotation-alignment"]),"icon-size":new el(nl.layout_symbol["icon-size"]),"icon-size-scale-range":new Qs(nl.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new el(nl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new el(nl.layout_symbol["icon-text-fit-padding"]),"icon-image":new el(nl.layout_symbol["icon-image"]),"icon-image-use-theme":new Qs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new el(nl.layout_symbol["icon-rotate"]),"icon-padding":new Qs(nl.layout_symbol["icon-padding"]),"icon-keep-upright":new Qs(nl.layout_symbol["icon-keep-upright"]),"icon-offset":new el(nl.layout_symbol["icon-offset"]),"icon-anchor":new el(nl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Qs(nl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Qs(nl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Qs(nl.layout_symbol["text-rotation-alignment"]),"text-field":new el(nl.layout_symbol["text-field"]),"text-font":new el(nl.layout_symbol["text-font"]),"text-size":new el(nl.layout_symbol["text-size"]),"text-size-scale-range":new Qs(nl.layout_symbol["text-size-scale-range"]),"text-max-width":new el(nl.layout_symbol["text-max-width"]),"text-line-height":new el(nl.layout_symbol["text-line-height"]),"text-letter-spacing":new el(nl.layout_symbol["text-letter-spacing"]),"text-justify":new el(nl.layout_symbol["text-justify"]),"text-radial-offset":new el(nl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Qs(nl.layout_symbol["text-variable-anchor"]),"text-anchor":new el(nl.layout_symbol["text-anchor"]),"text-max-angle":new Qs(nl.layout_symbol["text-max-angle"]),"text-writing-mode":new Qs(nl.layout_symbol["text-writing-mode"]),"text-rotate":new el(nl.layout_symbol["text-rotate"]),"text-padding":new Qs(nl.layout_symbol["text-padding"]),"text-keep-upright":new Qs(nl.layout_symbol["text-keep-upright"]),"text-transform":new el(nl.layout_symbol["text-transform"]),"text-offset":new el(nl.layout_symbol["text-offset"]),"text-allow-overlap":new Qs(nl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Qs(nl.layout_symbol["text-ignore-placement"]),"text-optional":new Qs(nl.layout_symbol["text-optional"]),visibility:new Qs(nl.layout_symbol.visibility)})),paint:Wv||(Wv=new il({"icon-opacity":new el(nl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new el(nl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new el(nl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new el(nl.paint_symbol["text-emissive-strength"]),"icon-color":new el(nl.paint_symbol["icon-color"]),"icon-halo-color":new el(nl.paint_symbol["icon-halo-color"]),"icon-halo-width":new el(nl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new el(nl.paint_symbol["icon-halo-blur"]),"icon-translate":new Qs(nl.paint_symbol["icon-translate"]),"icon-translate-anchor":new Qs(nl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Qs(nl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new el(nl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new el(nl.paint_symbol["text-occlusion-opacity"]),"text-color":new el(nl.paint_symbol["text-color"],{runtimeType:Tn,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new el(nl.paint_symbol["text-halo-color"]),"text-halo-width":new el(nl.paint_symbol["text-halo-width"]),"text-halo-blur":new el(nl.paint_symbol["text-halo-blur"]),"text-translate":new Qs(nl.paint_symbol["text-translate"]),"text-translate-anchor":new Qs(nl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Qs(nl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Qs(nl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Qs(nl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Qs(nl.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new el(nl.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},qv);class Qv extends zl{constructor(e,t,i,n){super(e,Kv(),t,i,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=d([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint);}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0);}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(i=>{i.recalculate(e,t,this.iconImageUseTheme);}),0!==this.appearances.length&&delete this.layout._values["text-variable-anchor"],"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"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.includes(t)||e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,t,i,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,i,n){e=St(e),t=Mt(t);const r=u(),o=e/3,a=1-2*o,s=[a,o,o,0,o,a,o,0,o,o,a,0,0,0,0,1],l=.5-.5*t,c=n-i;return _(r,[c,0,0,0,0,c,0,0,0,0,c,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,l,l,l,1]),_(r,r,s),r}(e,t,i,n),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Va(o.value)||!r?r:Yv(t.properties,r)}getAppearanceValueAndResolveTokens(e,t,i,n,r){const o=e.getLayoutProperty(t);if(!o)return;const a=o.evaluate(i,{},n,r),s=e.getUnevaluatedLayoutProperties()._values[t];return s.isDataDriven()||Va(s.value)||!a||"string"!=typeof a?a:Yv(i.properties,a)}createBucket(e){return new K_(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of Kv().paint.overridableProperties){if(!Qv.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Jv(t),n=new Na(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new Ua("source",n):new Ga("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Js(t.property,r,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,i){return !(!this.layout||t.isDataDriven()||i.isDataDriven())&&Qv.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Kv().paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof kn)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Wn&&$n(t.value)===Rn?o(t.value.sections):t instanceof Jn?o(t.sections):t.eachChild(e));},t=i.value;t._styleExpression&&e(t._styleExpression.expression);}return r}getProgramIds(){return ["symbol"]}getDefaultProgramParams(e,t,i){return {config:new fh(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}mayUse(e){return "HD"===e&&Rl(this,"symbol-elevation-reference",e=>"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?iv():Promise.resolve()}}let eb,tb,ib,nb;const rb=1024,ob=(Math.pow(rb,2)-1)/268170240;class ab extends zl{constructor(e,t,i,n){super(e,{layout:ib||(ib=new il({visibility:new Qs(nl.layout_raster.visibility)})),paint:nb||(nb=new il({"raster-opacity":new Qs(nl.paint_raster["raster-opacity"]),"raster-color":new tl(nl.paint_raster["raster-color"]),"raster-color-mix":new Qs(nl.paint_raster["raster-color-mix"]),"raster-color-range":new Qs(nl.paint_raster["raster-color-range"]),"raster-color-scale":new Qs(nl.paint_raster["raster-color-scale"]),"raster-hue-rotate":new Qs(nl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Qs(nl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Qs(nl.paint_raster["raster-brightness-max"]),"raster-saturation":new Qs(nl.paint_raster["raster-saturation"]),"raster-contrast":new Qs(nl.paint_raster["raster-contrast"]),"raster-resampling":new Qs(nl.paint_raster["raster-resampling"]),"raster-fade-duration":new Qs(nl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Qs(nl.paint_raster["raster-emissive-strength"]),"raster-array-band":new Qs(nl.paint_raster["raster-array-band"]),"raster-elevation":new Qs(nl.paint_raster["raster-elevation"]),"raster-elevation-reference":new Qs(nl.paint_raster["raster-elevation-reference"]),"raster-allow-draping":new Qs(nl.paint_raster["raster-allow-draping"]),"raster-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN];}getProgramIds(){return ["raster"]}hasColorMap(){return !!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){const t=e?e._source:null;return (!t||"image"!==t.type&&"video"!==t.type&&"canvas"!==t.type||!t.onNorthPole&&!t.onSouthPole)&&0===this.paint.get("raster-elevation")&&this.paint.get("raster-allow-draping")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e&&"raster-color-scale"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp());}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}updateColorRamp(e){if(!this.hasColorMap())return;if(!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[i,n]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];if(isNaN(i)&&isNaN(n))return;if(i===this._curRampRange[0]&&n===this._curRampRange[1])return;const r=this._transitionablePaint._values["raster-color-scale"].value.expression.evaluate({zoom:0});this.colorRamp=yv({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:i,end:n}],resolution:rb,scale:r}),this.colorRampTexture=null,this._curRampRange=[i,n];}is3D(e){return this.paint.get("raster-elevation")>0||!this.paint.get("raster-allow-draping")}}let sb,lb,ub,cb,hb,db,fb;class pb extends zl{constructor(e,t,i,n){super(e,{layout:sb||(sb=new il({visibility:new Qs(nl["layout_raster-particle"].visibility)})),paint:lb||(lb=new il({"raster-particle-array-band":new Qs(nl["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Qs(nl["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new tl(nl["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Qs(nl["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Qs(nl["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Qs(nl["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Qs(nl["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Qs(nl["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp(),this.lastInvalidatedAt=Vt.now();}mayUse(e){return "HD"===e}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null);}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isDraped(e){return !1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=yv({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=Vt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class _b extends zl{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(e){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}function mb(e,t,i){const n=[0,0,1],r=ce([]);return fe(r,r,i?-Ye(e)+Math.PI:Ye(e)),de(r,r,-Ye(t)),K(n,n,r),Z(n,n)}class gb{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class yb{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new vc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}colorForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let n=Math.floor(i[t+2]);const r=1.05*(i[t+2]-n);return n/=100,[i[t]%1*1.05,i[t+1]%1*1.05,r,n]}tileCoordinatesForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let n=i[t+0];return n=n>Sr?n-Sr:n,new Pe(Math.trunc(n),Math.trunc(i[t+1]))}translationForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return [i[t+4],i[t+5],i[t+6]]}rotationScaleForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return [i[t+7],i[t+8],i[t+9],i[t+10],i[t+11],i[t+12],i[t+13],i[t+14],i[t+15]]}transformForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return [i[t+7],i[t+8],i[t+9],i[t+4],i[t+10],i[t+11],i[t+12],i[t+5],i[t+13],i[t+14],i[t+15],i[t+6],0,0,0,1]}}class xb{constructor(e){this.requiresStandardRuntime=!0,this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.tileToMeter=Au(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const o="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=s??(a.properties&&Object.hasOwn(a.properties,"id")?a.properties.id:void 0),c=Fu(a,r);if(!this.layers[0]._featureFilter.filter(new Hs(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const h={id:e,sourceLayerIndex:u,index:l,geometry:r?c.geometry:Cu(a,i,n),properties:a.properties,type:a.type,patterns:{}},d=this.addFeature(h,h.geometry,c,o,i);d&&t.featureIndex.insert(a,h.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256);}this.lookup=null;}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const n of this.modelUris){const r=e.getModel(n,t);if(!r)continue;const o=this.instancesPerModel[n];if(o){const e=.5*G(r.aabb.max,r.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Sr,Math.max(e/this.tileToMeter,256));i=Math.max(t,i);}}return i}update(e,t,i,n){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)Object.hasOwn(i.idToFeaturesIndex,t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const n=this.layers[0],r=t.feature,o=this.canonical,a=n.paint.get("model-rotation").evaluate(r,{},o),s=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);ee(t.rotation,a)&&ee(t.scale,s)&&ee(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0);}}return e}updateReplacement(e,t,i,n){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Lp(this.activeReplacements,r))return !1;this.activeReplacements=r;let o=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],a=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,s=t.instancedDataCount;for(let t=0;t<s;t++){const s=16*(t+r);let l=a.float32[s+0];const u=l>Sr;l=u?l-Sr:l;const c=Math.floor(l),h=Math.floor(a.float32[s+1]);let d=!1;for(const t of this.activeReplacements)if(!Dp(t,i,ex.Model,n)&&!(t.min.x>c||c>t.max.x||t.min.y>h||h>t.max.y)&&(d=Gp(Up(c,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;a.float32[s]=d?l+Sr:l,o=o||d!==u;}}}return o}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,Yg.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0);}addFeature(e,t,i,n,r){const o=this.layers[0],a=o.layout.get("model-id"),s=o.layout.get("model-allow-density-reduction"),l=a.evaluate(i,{},this.canonical);if(!l)return mt(`modelId is not evaluated for layer ${o.id} and it is not going to get rendered.`),l;!l.includes("://")&&!this.styleDefinedModelURLs[l]||this.modelUris.includes(l)||this.modelUris.push(l),this.instancesPerModel[l]||(this.instancesPerModel[l]=new yb);const u=this.instancesPerModel[l],c=u.instancedDataArray,h=new gb(i,c.length);let d;if(n){const t=ym(e,n,void 0,r);d=t?t.feature:void 0;}for(const e of t)for(const t of e){if(t.x<0||t.x>=Sr||t.y<0||t.y>=Sr)continue;if(0!==this.lookupDim&&s){const e=(this.lookupDim-1)/Sr,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1;}}this.instanceCount++;const e=c.length;if(c.resize(e+1),n){u.instancesRoadElevation||(u.instancesRoadElevation=[]);const e=d?d.pointElevation(new Pe(t.x,t.y)):0;u.instancesRoadElevation.push(e);}u.instancesEvaluatedElevation.push(0),c.float32[16*e]=t.x,c.float32[16*e+1]=t.y;}return h.instancedDataCount=u.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(h),this.evaluate(h,{},u,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,i,n){const r=this.layers[0],o=e.feature,a=this.canonical,s=e.rotation=r.paint.get("model-rotation").evaluate(o,t,a),l=e.scale=r.paint.get("model-scale").evaluate(o,t,a),u=e.translation=r.paint.get("model-translation").evaluate(o,t,a),{r:c,g:h,b:d}=r.paint.get("model-color").evaluate(o,t,a),f=r.paint.get("model-color-mix-intensity").evaluate(o,t,a),p=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]);const _=u[0]*u[0]+u[1]*u[1],m=_>0?Math.sqrt(_):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,m),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),oy(p,s,l);const g=Math.round(100*f)+d/1.05;for(let t=0;t<e.instancedDataCount;++t){const r=e.instancedDataOffset+t,o=16*r,s=i.instancedDataArray.float32;let l=0;n&&(l=s[o+6]-i.instancesEvaluatedElevation[r]);const d=0|s[o+1];s[o]=(0|s[o])+c/1.05,s[o+1]=d+h/1.05,s[o+2]=g,s[o+3]=1/(a.z>10?this.tileToMeter:Au(a,d)),s[o+4]=u[0],s[o+5]=u[1],s[o+6]=u[2]+(i.instancesRoadElevation?i.instancesRoadElevation[r]:0)+l,s[o+7]=p[0],s[o+8]=p[1],s[o+9]=p[2],s[o+10]=p[4],s[o+11]=p[5],s[o+12]=p[6],s[o+13]=p[8],s[o+14]=p[9],s[o+15]=p[10],i.instancesEvaluatedElevation[r]=u[2];}}}qa(xb,"ModelBucket",{omit:["layers"]}),qa(yb,"PerModelAttributes"),qa(gb,"ModelFeature");class vb{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i;}static create(e,t,i){const n=i||e.findDEMTileFor(t);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,a=1<<t.canonical.z-o.canonical.z;return new vb(n,r.dim/Sr/a,[(t.canonical.x/a-o.canonical.x)*r.dim,(t.canonical.y/a-o.canonical.y)*r.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1];return new Pe(Math.floor(e*this._scale+this._offset[0]),Math.floor(i))}getElevationAt(e,t,i,n){const r=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],a=Math.floor(r),s=Math.floor(o),l=this._dem;return n=!!n,i?dn(dn(l.get(a,s,n),l.get(a,s+1,n),o-s),dn(l.get(a+1,s,n),l.get(a+1,s+1,n),o-s),r-a):l.get(a,s,n)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return (1<<this._demTile.tileID.canonical.z)*yu(1,e)*this._dem.stride}}const bb=new Float32Array(262144),wb=new Uint8Array(262144),Eb=[0,0,0],Ab=[0,0,0];function Ib(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,Ib(i));return t}function Tb(e,t,i){if(e.meshes)for(const n of e.meshes){if(n.aabb.min[0]===1/0)continue;const r=zf.applyTransform(n.aabb,e.globalMatrix);i.insert(t,r.min[0],r.min[1],r.max[0],r.max[1]);}if(e.children)for(const n of e.children)Tb(n,t,i);}const Mb=["","wall","door","roof","window","lamp","logo"];class Sb{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.targetLod=-1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Ib(e)}},this.aabb=this._getLocalBounds(),this.state=null;}_getLocalBounds(){if(!this.node.meshes)return new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&(i.transformedAabb=zf.applyTransformFast(i.aabb,this.node.globalMatrix),t.encapsulate(i.transformedAabb)),e++;this.aabb=t;}return this.aabb}}class zb{constructor(e,t,i,n,r,o,a,s){this.requiresStandardRuntime=!0,this.isTiled3dModelBucket=!0,this.id=i,this.layers=e,this.layerIds=this.layers.map(e=>e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=4),r&&(this.modelTraits|=8),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=s,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Sb(e)),Tb(e,a.featureIndexArray.length,a.grid),a.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,a.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null;}updateFootprints(e,t){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&t.push({footprint:n.footprint,id:e});}}updateAppearances(e,t,i,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!De(e,this.states))for(const t of i)this.evaluate(t,e);this.states=structuredClone(e);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):_y(t,e,!0);}for(const e of t)gy(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);if(e.lodMeshes)for(const i of e.lodMeshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const n=e.transform.projectionOptions,r=e.style.getBrightness(),o=this.brightness!==r;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Rb(i.paint.get("model-color").value,o)||Rb(i.paint.get("model-color-mix-intensity").value,o)||Rb(i.paint.get("model-roughness").value,o)||Rb(i.paint.get("model-emissive-strength").value,o)||Rb(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=n,this.brightness=r;const e=this.getNodesInfo();for(const t of e)t.state=null;return !0}return !1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},n);}}evaluate(e,t){const i=this.getNodesInfo();for(const n of i){if(!n.node.meshes)continue;const i=n.feature,r=t&&t[i.id];if(De(r,n.state))continue;n.state=structuredClone(r);const o=n.node.meshes&&n.node.meshes[0].featureData,a=n.evaluatedColor[2],s=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,o){for(let t=0;t<Mb.length;t++){const o=Mb[t];o.length&&(i.properties.part=o);const a=e.paint.get("model-color").evaluate(i,r,l).toPremultipliedRenderColor(null),s=e.paint.get("model-color-mix-intensity").evaluate(i,r,l);n.evaluatedColor[t]=[a.r,a.g,a.b,s],n.evaluatedRMEA[t][0]=e.paint.get("model-roughness").evaluate(i,r,l),n.evaluatedRMEA[t][2]=e.paint.get("model-emissive-strength").evaluate(i,r,l),n.evaluatedRMEA[t][3]=a.a,n.emissionHeightBasedParams[t]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(i,r,l),!n.hasTranslucentParts&&a.a<1&&(n.hasTranslucentParts=!0);}delete i.properties.part,Fb(n,a!==n.evaluatedColor[2]||s!==n.evaluatedRMEA[2],this.modelTraits);}else n.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(i,r,l);n.evaluatedTranslation=e.paint.get("model-translation").evaluate(i,r,l),n.evaluatedScale=e.paint.get("model-scale").evaluate(i,r,l),this.updatePbrBuffer(n.node)||(this.needsUpload=!0);}this.dirty=!1;}elevationUpdate(e,t,i,n){const r=e.findDEMTileFor(i);if(r&&(r.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(r.dem&&r.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=r.tileID.overscaledZ;const t=vb.create(e,i,r);if(!t)return;4&this.modelTraits&&this.updateDEM(e,t,i,n);for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.vertices||!i.footprint.vertices.length)continue;const n=i.footprint.vertices;let r=t.getElevationAt(n[0].x,n[0].y,!0,!0);for(let e=1;e<n.length;e++)r=Math.min(r,t.getElevationAt(n[e].x,n[e].y,!0,!0));i.elevation=r;}}this.terrainTile=r.tileID.canonical,this.terrainExaggeration=t;}}updateDEM(e,t,i,n){let r=t._dem._modifiedForSources[n];if(void 0===r&&(t._dem._modifiedForSources[n]=[],r=t._dem._modifiedForSources[n]),r.includes(i.canonical))return;const o=t._dem.dim;r.push(i.canonical);let a=!1;for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.grid)continue;const n=i.footprint.grid,r=t.tileCoordToPixel(n.min.x,n.min.y),s=t.tileCoordToPixel(n.max.x,n.max.y),l=Math.min(Math.min(o-s.y,r.x),Math.min(r.y,o-s.x));if(l<0)continue;const u=tt(l,2,5);let c=Math.max(0,r.x-u),h=Math.max(0,r.y-u),d=Math.min(s.x+u,o-1),f=Math.min(s.y+u,o-1);for(let e=h;e<=f;++e)for(let t=c;t<=d;++t)wb[e*o+t]=255;let p=0,_=0;for(let e=0;e<n.cellsY;++e)for(let i=0;i<n.cellsX;++i){if(!n.cells[e*n.cellsX+i])continue;const r=t.tileCoordToPixel(n.min.x+i/n.xScale,n.min.y+e/n.yScale),a=t.tileCoordToPixel(n.min.x+(i+1)/n.xScale,n.min.y+(e+1)/n.yScale);for(let e=r.y;e<=Math.min(a.y+1,o-1);++e)for(let i=r.x;i<=Math.min(a.x+1,o-1);++i)255===wb[e*o+i]&&(wb[e*o+i]=0,p+=t.getElevationAtPixel(i,e),_++);}const m=p/_;c=Math.max(1,r.x-u),h=Math.max(1,r.y-u),d=Math.min(s.x+u,o-2),f=Math.min(s.y+u,o-2),a=!0;for(let e=h;e<=f;++e)for(let i=c;i<=d;++i)0===wb[e*o+i]&&(bb[e*o+i]=t._dem.set(i,e,m));for(let e=1;e<u;++e){c=Math.max(1,r.x-e),h=Math.max(1,r.y-e),d=Math.min(s.x+e,o-2),f=Math.min(s.y+e,o-2);for(let i=h;i<=f;++i)for(let n=c;n<=d;++n){const r=i*o+n;if(255===wb[r]){let a=0,s=0,l=-1,c=-1;for(let t=-1;t<=1;++t)for(let r=-1;r<=1;++r){const u=(i+t)*o+n+r;if(wb[u]>=e)continue;const h=bb[u],d=Math.abs(h);d>s&&(a=h,s=d,l=r,c=t);}if(s>.1){const o=1-(e+.5*Math.abs(l*c))/u;let s=t._dem.get(n,i)+a*o;const h=t._dem.get(n+l,i+c),d=t._dem.get(n-l,i-c,!0);(s-h)*(s-d)>0&&(s=(h+d)/2),bb[r]=t._dem.set(n,i,s),wb[r]=e;}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Vt.now());}setFilter(e){this.filter=e?sl(e):null;}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Hs(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)gy(t.node),xy(t.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!i.some(e=>e.footprint===t);}}getHeightAtTileCoord(e,t){const i=[0,0,0],n=d([]);for(const r of this.getNodesInfo()){const o=r.node.meshes[0],a=o.transformedAabb;if(e<a.min[0]||t<a.min[1]||e>a.max[0]||t>a.max[1])continue;if(!0===r.node.hidden)return {height:1/0,maxHeight:r.feature.properties.height,hidden:!1,verticalScale:r.evaluatedScale[2]};if(p(n,r.node.globalMatrix),i[0]=e,i[1]=t,i[2]=0,Y(i,i,n),r.node.meshBVH){const e=i[0],t=i[1];Eb[0]=e-1,Eb[1]=t-1,Eb[2]=-1e3,Ab[0]=e+1,Ab[1]=t+1,Ab[2]=1e3;const n=r.node.meshBVH.findHighestPoint(Eb,Ab);if(null!==n)return {height:n,maxHeight:r.feature.properties.height,hidden:r.hiddenByReplacement,verticalScale:r.evaluatedScale[2]};continue}const s=(i[0]-o.aabb.min[0])/(o.aabb.max[0]-o.aabb.min[0])*uy|0,l=Math.min(63,(i[1]-o.aabb.min[1])/(o.aabb.max[1]-o.aabb.min[1])*uy|0)*uy+Math.min(63,s),u=o.heightmap[l];if(u<0&&r.node.footprint){const i=[];if(r.node.footprint.grid.query(new Pe(e,t),new Pe(e,t),i),i.length>0)return {height:void 0,maxHeight:r.feature.properties.height,hidden:r.hiddenByReplacement,verticalScale:r.evaluatedScale[2]};continue}if(r.hiddenByReplacement)return;return {height:u,maxHeight:r.feature.properties.height,hidden:!1,verticalScale:r.evaluatedScale[2]}}}}function Rb(e,t){return e instanceof Ua&&!e.isLightConstant&&t}function Pb(e){const t=tt(e,0,2);return Math.min(Math.round(.5*t*255),255)}const Db=new Float64Array(10*Mb.length);function Cb(e,t,i,n,r,o){if(!e.featureData)return;const a=e.featureArray=new bc;a.reserveExact(e.featureData.length),function(e,t,i){const n=i-t;for(let i=0;i<Mb.length;i++){const r=e.evaluatedRMEA[i],o=e.evaluatedColor[i],a=e.emissionHeightBasedParams[i],s=tt(a[0],0,1),l=tt(a[1],0,1);let u=65535,c=0,h=1,d=1;if(s!==l&&0!==n){const e=tt(a[2],0,1),i=tt(a[3],0,1),r=n*(l-s);c=1/r,h=-(t+n*s)/r,d=Math.pow(10,tt(a[4],-1,1)),u=255*e<<8|255*i;}const f=Db,p=10*i;f[p]=255*o[0],f[p+1]=255*o[1],f[p+2]=255*o[2],f[p+3]=o[3],f[p+4]=Math.floor(255*r[3]),f[p+5]=Pb(r[2])<<8|15*r[0]<<4|15*r[1],f[p+6]=u,f[p+7]=c,f[p+8]=h,f[p+9]=d;}}(t,e.aabb.min[2],e.aabb.max[2]);const s=Db,l=t.node;let u=r&&!!l.lights;for(const t of e.featureData){const e=t>>i&65535,r=t>>n&15,c=r<8?r:0,h=10*c;let d=(61440&e|(61440&e)>>4)>>8,f=(3840&e|(3840&e)>>4)>>4,p=240&e|(240&e)>>4;const _=(15&e|(15&e)<<4)/255,m=s[h+3];m>0&&(d=dn(d,s[h],m),f=dn(f,s[h+1],m),p=dn(p,s[h+2],m)),o&&(d*=_,f*=_,p*=_);const g=d<<8|f,y=p<<8|s[h+4],x=s[h+5],v=s[h+6],b=s[h+7],w=s[h+8],E=s[h+9];if(a.emplaceBack(g,y,x,v,b,w,E),u&&2===c){u=!1;const e=10*l.lights.length,t=new bc;t.reserveExact(e);for(let i=0;i<e;i++)t.emplaceBack(g,y,x,v,b,w,E);l.meshes[l.lightMeshIndex].featureArray=t;}}}function Fb(e,t,i){const n=e.node,r=8&i,o=r?0:16,a=r?16:0;for(let i=0;i<n.meshes.length;i++)n.lights&&n.lightMeshIndex===i||Cb(n.meshes[i],e,o,a,t,!1);if(n.lodMeshes)for(const t of n.lodMeshes)Cb(t,e,o,a,!1,!0);}qa(zb,"Tiled3dModelBucket",{omit:["layers"]}),qa(Sb,"Tiled3dModelFeature");class Ob{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){return this._numberToString[e]}}const Lb=["id","tile","layer","source","sourceLayer","state"];class Bb{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=n,this.properties=e?e.properties:{},this.id=r;}clone(){const e=new Bb(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state={...this.state}),this.layer&&(e.layer={...this.layer}),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e;}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of Lb)void 0!==this[t]&&(e[t]=this[t]);return e}}const Nb={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11},Vb=new Float32Array(d([])),kb=[0,0,0],Ub=(e,t,i,n,r,o,s,u,c,h,d,f,p,_=[0,0,0],m,g,y,x=1,v=!1)=>{let b=kb,w=0,E=kb;if(!v){const e=r.style.light,t=e.properties.get("position");if(b=[-t.x,-t.y,t.z],"viewport"===e.properties.get("anchor")){const e=a();l(e,-r.transform.angle),J(b,b,e);}const i=e.properties.get("color").toNonPremultipliedRenderColor(null);w=e.properties.get("intensity"),E=[i.r,i.g,i.b];}const A="MASK"===d.alphaMode,I=p.paint.get("model-ambient-occlusion-intensity"),T=p.paint.get("model-color").constantOr(pn.white).toNonPremultipliedRenderColor(null);return T.a=p.paint.get("model-color-mix-intensity").constantOr(0),y&&(T.r=y[0],T.g=y[1],T.b=y[2],T.a=y[3]),g&&(T.r=g.color.r,T.g=g.color.g,T.b=g.color.b,T.a=g.colorMix,f=g.emissionStrength,o*=g.opacity),{u_matrix:e,u_lighting_matrix:t,u_normal_matrix:i,u_node_matrix:n||Vb,u_lightpos:b,u_lightintensity:w,u_lightcolor:E,u_camera_pos:_,u_opacity:o,u_baseTextureIsAlpha:0,u_alphaMask:+A,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:s.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:u.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:Nb.BaseColor,u_metallicRoughnessTexture:Nb.MetallicRoughness,u_normalTexture:Nb.Normal,u_occlusionTexture:Nb.Occlusion,u_emissionTexture:Nb.Emission,u_lutTexture:Nb.LUT,u_color_mix:T.toArray01(),u_aoIntensity:I,u_emissive_strength:f,u_occlusionTextureTransform:m||[0,0,0,0],u_dithered_discard_threshold:x}},Gb=(e,t=Vb,i=Vb)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),jb=7680;class Hb{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o;}}Hb.disabled=new Hb({func:519,mask:0},0,0,jb,jb,jb);const $b=770,Zb=771;class Wb{constructor(e,t,i,n){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=n;}}Wb.Replace=[1,0,1,0],Wb.disabled=new Wb(Wb.Replace,pn.transparent,[!1,!1,!1,!1]),Wb.unblended=new Wb(Wb.Replace,pn.transparent,[!0,!0,!0,!0]),Wb.alphaBlended=new Wb([1,Zb,1,Zb],pn.transparent,[!0,!0,!0,!0]),Wb.alphaBlendedNonPremultiplied=new Wb([$b,Zb,$b,Zb],pn.transparent,[!0,!0,!0,!0]),Wb.multiply=new Wb([774,0,774,0],pn.transparent,[!0,!0,!0,!0]),Wb.multiplyAccumulateAlpha=new Wb([774,0,1,Zb],pn.transparent,[!0,!0,!0,!0]),Wb.additive=new Wb([1,1,1,1],pn.transparent,[!0,!0,!0,!0]),Wb.additiveAlphaWeighted=new Wb([$b,1,773,1],pn.transparent,[!0,!0,!0,!0]),Wb.additiveAlphaWeightedUnboundedAlpha=new Wb([$b,1,1,1],pn.transparent,[!0,!0,!0,!0]);class qb{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}qb.ReadOnly=!1,qb.ReadWrite=!0,qb.disabled=new qb(519,qb.ReadOnly,[0,1]);const Xb=1029,Yb=2305;class Jb{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Jb.disabled=new Jb(!1,Xb,Yb),Jb.backCCW=new Jb(!0,Xb,Yb),Jb.backCW=new Jb(!0,Xb,2304),Jb.frontCW=new Jb(!0,1028,2304),Jb.frontCCW=new Jb(!0,1028,Yb);class Kb{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n;}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=dn(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=dn(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=dn(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=dn(e.right,t.right,i)),this}getCenter(e,t){return new Pe(tt((this.left+e-this.right)/2,0,e),tt((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 Kb(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qb(e,t){const i=At(e,3);T(e,t),It(e,3,i);}function ew(e,t){const i=ce([]);return pe(i,i,-t),de(i,i,-e),i}function tw(e,t){const i=[e[0],e[1],0],n=[t[0],t[1],0];if(D(i)>=1e-15){const e=Z([],i);k(n,e,W(n,e)),t[0]=n[0],t[1]=n[1];}const r=q([],t,e);if(ne(r)<1e-15)return null;const o=Math.atan2(-r[1],r[0]);return ew(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class iw{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(e){if(e){const t=e instanceof Iu?e:new Iu(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=nt(t.x,0,1)),this._position=t;}else this._position=null;}lookAtPoint(e,t,i){if(this.orientation=null,!this.position)return;const n=this.position,r=i||(this._elevation?this._elevation.getAtPointOrZero(Iu.fromLngLat(e)):0),o=Iu.fromLngLat(e,r),a=[o.x-n.x,o.y-n.y,o.z-n.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=tw(a,t);}setPitchBearing(e,t){this.orientation=ew(Ye(e),Ye(-t));}}class nw{constructor(e,t){this._transform=d([]),this.orientation=t,this.position=e;}get mercatorPosition(){const e=this.position;return new Iu(e[0],e[1],e[2])}get position(){const e=At(this._transform,3);return [e[0],e[1],e[2]]}set position(e){var t;e&&It(this._transform,3,[(t=e)[0],t[1],t[2],1]);}get orientation(){return this._orientation}set orientation(e){this._orientation=e||ce([]),e&&Qb(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=ew(e,t),Qb(this._transform,this._orientation);}forward(){const e=At(this._transform,2);return [-e[0],-e[1],-e[2]]}up(){const e=At(this._transform,1);return [-e[0],-e[1],-e[2]]}right(){const e=At(this._transform,0);return [e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return p(i,this.getWorldToCamera(e,t)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,i){const n=this.position;k(n,n,-e);const r=new Float64Array(16);return w(r,[i,i,i]),m(r,r,n),r[10]*=t,r}getWorldToCamera(e,t){const i=new Float64Array(16),n=new Float64Array(4),r=this.position;var o,a;return (o=n)[0]=-(a=this._orientation)[0],o[1]=-a[1],o[2]=-a[2],o[3]=a[3],k(r,r,-e),T(i,n),m(i,i,r),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,n){const r=new Float64Array(16);return M(r,e,t,i,n),r}getCameraToClipOrthographic(e,t,i,n,r,o){const a=new Float64Array(16);return S(a,e,t,i,n,r,o),a}getDistanceToElevation(e,t=!1){const i=0===e?0:yu(e,t?pr(this.position[1]):this.position[1]),n=this.forward();return (i-this.position[2])/n[2]}clone(){return new nw([...this.position],[...this.orientation])}}const rw=Math.tan(85*Math.PI/180);function ow(e,t,i,n,r,a,s){const l=u();if(i)if("globe"===a.name){const e=function(e,t){const{x:i,y:n}=e.point,r=qf(i,n,e.worldSize/e._pixelsPerMercatorPixel,0,0);return _(r,r,$f(Of(t)))}(r,t);_(l,l,e);}else {const e=o([],s);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],n||v(l,l,r.angle);}else _(l,r.labelPlaneMatrix,e);return l}function aw(e,t,i,n){const r=[e,t,i,1];i?le(r,r,n):gw(r,r,n);const o=r[3];return r[0]/=o,r[1]/=o,r[2]/=o,r}function sw(e,t){return Math.min(.5+e/t*.5,1.5)}function lw(e,t){const i=e[0]/e[3],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function uw(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g){const{lineStartIndex:y,glyphStartIndex:x,segment:v}=s,b=x+s.numGlyphs,w=y+s.lineLength,E=t.getoffsetX(x),A=t.getoffsetX(b-1),I=_w(e*E,i,n,r,o,a,v,y,w,l,u,c,h,d,!0,f,p,_,m,g);if(!I)return null;const T=_w(e*A,i,n,r,o,a,v,y,w,l,u,c,h,d,!0,f,p,_,m,g);return T?{first:I,last:T}:null}function cw(e,t,i,n){return e===qd.horizontal&&Math.abs(n)>Math.abs(i)?{useVertical:!0}:e===qd.vertical?n>0?{needsFlipping:!0}:null:0!==t&&function(e,t){return 0===e||Math.abs(t/e)>rw}(i,n)?1===t?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function hw(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x,v){const b=t/24,w=e.lineOffsetX*b,E=e.lineOffsetY*b,{lineStartIndex:A,glyphStartIndex:I,numGlyphs:T,segment:M,writingMode:S,flipState:z}=e,R=A+e.lineLength,P=e=>{if(c){const[t,i,n]=e.up,r=u.length;Z_(c,r+0,t,i,n),Z_(c,r+1,t,i,n),Z_(c,r+2,t,i,n),Z_(c,r+3,t,i,n);}const[t,i,n]=e.point;W_(u,t,i,n,e.angle);};if(T>1){const t=uw(b,s,w,E,i,h,d,e,l,o,f,_,!1,m,g,y,x,v);if(!t)return {notEnoughRoom:!0};if(n&&!i){let[i,n,r]=t.first.point,[o,s,l]=t.last.point;[i,n]=aw(i,n,r,a),[o,s]=aw(o,s,l,a);const u=cw(S,z,(o-i)*p,s-n);if(e.flipState=u&&u.needsFlipping?1:2,u)return u}P(t.first);for(let e=I+1;e<I+T-1;e++){const t=_w(b*s.getoffsetX(e),w,E,i,h,d,M,A,R,l,o,f,_,!1,!1,m,g,y,x,v);if(!t)return u.length-=4*(e-I),{notEnoughRoom:!0};P(t);}P(t.last);}else {if(n&&!i){const t=aw(d.x,d.y,0,r),i=A+M+1,n=new Pe(l.getx(i),l.gety(i)),o=aw(n.x,n.y,0,r),a=o[3]>0?o:pw(d,n,t,1,r,void 0,m,g.canonical),s=cw(S,z,(a[0]-t[0])*p,a[1]-t[1]);if(e.flipState=s&&s.needsFlipping?1:2,s)return s}const t=_w(b*s.getoffsetX(I),w,E,i,h,d,M,A,R,l,o,f,_,!1,!1,m,g,y,x,v);if(!t)return {notEnoughRoom:!0};P(t);}return {}}function dw(e,t,i){const n=1<<t.z;let r=(e.x/Sr+t.x)/n-i.mercCenter[0];const o=(e.y/Sr+t.y)/n-i.mercCenter[1];r-=Math.round(r);const a=[r*Sr,o*Sr,Sr/(2*Math.PI),1];return le(a,a,i.invMatrix),[a[0],a[1],a[2]]}function fw(e,t,i,n,r,o){let{x:a,y:s,z:l}=n.projectTilePoint(e.x,e.y,t);if(o){const[i,n,r]=dw(e,t,o);a+=(i-a)*o.t,s+=(n-s)*o.t,l+=(r-l)*o.t;}if(!r)return aw(a,s,l,i);const[u,c,h]=r.getElevation(e,r.elevation,r.elevationFeature);return aw(a+u,s+c,l+h,i)}function pw(e,t,i,n,r,o,a,s,l){const u=fw(e.sub(t)._unit()._add(e),s,r,a,o,l);return te(u,i,u),Z(u,u),U(u,i,u,n)}function _w(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y,x){const v=n?e-t:e+t;let b=v>0?1:-1,w=0;n&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let E=s+a+(b>0?0:1)|0,A=r,I=r,T=0,M=0;const S=Math.abs(v),z=[],R=[];let P=o,D=P,C=Q([]);const F=()=>pw(D,P,I,S-T+1,c,d,_,m.canonical,x);for(;T+M<=S;){if(E+=b,E<s||E>=l)return null;if(I=A,D=P,z.push(I),f&&R.push(D),P=new Pe(u.getx(E),u.gety(E)),A=h[E],!A){const e=fw(P,m.canonical,c,_,d,x);A=e[3]>0?h[E]=e:F();}T+=M;const e=te([],A,I),t=G(I,A);if(i&&t>0&&M>0&&W(C,e)/(M*t)<y)return null;M=t,C=e;}p&&d&&(h[E]&&(A=F(),M=G(I,A),C=te([],A,I)),h[E]=A);const O=(S-T)/M,L=P.sub(D)._mult(O)._add(D),B=U([],I,C,O);let N=[0,0,1],V=C[0],k=C[1];if(g&&(N=_.upVector(m.canonical,L.x,L.y),0!==N[0]||0!==N[1]||1!==N[2])){const e=[N[2],0,-N[0]],t=q([],N,e);Z(e,e),Z(t,t),V=W(C,e),k=W(C,t);}if(i){const e=q([],N,C);Z(e,e),U(B,B,e,i*b);}const j=w+Math.atan2(k,V);return z.push(B),f&&R.push(L),{point:B,angle:j,path:z,tilePath:R,up:N}}function mw(e,t){const i=t.length,n=i+4*e;t.resize(n),t.float32.fill(-1/0,4*i,4*n);}function gw(e,t,i){const n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e[3]=i[3]*n+i[7]*r+i[15],e}const yw=15;class xw{constructor(e,t,i,n,r,o,a){this.tileSize=512,this._renderWorldCopies=void 0===r||r,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=i??0,this._maxPitch=n??60,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new _u(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new Kb,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new nw,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatrix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16);}clone(){const e=new xw(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._nearClipOffset=this._nearClipOffset,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<yw}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(e){this._nearClipOffset=e,this._calcMatrices();}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return ot(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=zp(this.projectionOptions);const i=!De(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=zp({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return yu(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new Pe(this.width,this.height)}get bearing(){return nt(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;if(this.angle===t)return;this._unmodified=!1,this.angle=t,this._calcMatrices();const i=Math.sin(this.angle),n=Math.cos(this.angle);this.rotationMatrix=[n,i,-i,n];}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=tt(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=Ye(e),this._calcMatrices());}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}get horizontalFov(){return Je(2*Math.atan(Math.tan(.5*this._fov)*this.aspect))}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e);}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let n=0,r=0;for(let o=0;o<t.length;o++){const a=new Pe(t[o][0]*this.width,i+t[o][1]*(this.height-i)),s=e.pointCoordinate(a);if(!s)continue;const l=1/Math.hypot(s[0]-this._camera.position[0],s[1]-this._camera.position[1]);n+=s[3]*l,r+=l;}return 0===r?NaN:n/r}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices());}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,n=this._mercatorZfromZoom(e),r=this._mercatorZfromZoom(this._maxZoom),o=Math.max(n-i,r);this._setZoom(this._zoomFromMercatorZ(o));}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}equals(e){const t=this.elevation,i=e.elevation,n=null!=t!=(null!=i)||t&&i&&t.exaggeration()!==i.exaggeration();return this.width===e.width&&this.height===e.height&&this.center.lng===e.center.lng&&this.center.lat===e.center.lat&&this.zoom===e.zoom&&this.bearing===e.bearing&&this.pitch===e.pitch&&this.fov===e.fov&&this.projection.name===e.projection.name&&this._edgeInsets.equals(e.padding)&&!n}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const n=D(te([],this._camera.position,i));return tt(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!((i=e.orientation)[0]===(n=this._camera.orientation)[0]&&i[1]===n[1]&&i[2]===n[2]&&i[3]===n[3])&&(t=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];ee(i,this._camera.position)||(this._setCameraPosition(i),t=!0);}var i,n;t&&(this._updateStateFromCamera(),this.recenterOnTerrain());}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new iw;return t.position=new Iu(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(!function(e){var t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)}(e))return !1;ye(e,e);const t=K([],[0,0,-1],e),i=K([],[0,-1,0],e);if(i[2]<0)return !1;const n=tw(t,i);return !!n&&(this._camera.orientation=n,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;e[2]=tt(e[2],n/i,n/t),this._camera.position=e;}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(e){const t=[new np(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new Pe(0,0)),n=this.pointCoordinate(new Pe(this.width,0)),r=this.pointCoordinate(new Pe(this.width,this.height)),o=this.pointCoordinate(new Pe(0,this.height)),a=Math.floor(Math.min(i.x,n.x,r.x,o.x)),s=Math.floor(Math.max(i.x,n.x,r.x,o.x)),l=1;for(let i=a-l;i<=s+l;i++)0!==i&&t.push(new np(i,e));}return t}isLODDisabled(e){return (!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(e,t,i,n){let r=[];const o=null!=i,a=!o;if(a&&this.zoom<t)return r;if(o&&0===i[0]&&0===i[1])return r;const s=new Set,l=(e,t,i,n,o)=>{const a=op(t,e,i,n,o);s.has(a)||(r.push(new rp(e,t,i,n,o)),s.add(a));};for(let r=0;r<e.length;r++){const s=e[r];if(a&&s.canonical.z!==t)continue;if(o&&void 0!==n&&n>s.canonical.z)continue;const u=s.canonical,c=s.overscaledZ,h=s.wrap,d=1<<u.z,f=u.x+1<d,p=u.x>0,_=u.y+1<d,m=u.y>0,g=s.wrap-(p?0:1),y=s.wrap+(f?0:1),x=p?u.x-1:d-1,v=f?u.x+1:0;if(o)i[0]<0?(l(c,y,u.z,v,u.y),i[1]<0&&_&&(l(c,h,u.z,u.x,u.y+1),l(c,y,u.z,v,u.y+1)),i[1]>0&&m&&(l(c,h,u.z,u.x,u.y-1),l(c,y,u.z,v,u.y-1))):i[0]>0?(l(c,g,u.z,x,u.y),i[1]<0&&_&&(l(c,h,u.z,u.x,u.y+1),l(c,g,u.z,x,u.y+1)),i[1]>0&&m&&(l(c,h,u.z,u.x,u.y-1),l(c,g,u.z,x,u.y-1))):i[1]<0&&_?l(c,h,u.z,u.x,u.y+1):m&&l(c,h,u.z,u.x,u.y-1);else {const e=s.visibleQuadrants;1&e&&(l(c,g,u.z,x,u.y),m&&(l(c,h,u.z,u.x,u.y-1),l(c,g,u.z,x,u.y-1))),2&e&&(l(c,y,u.z,v,u.y),m&&(l(c,h,u.z,u.x,u.y-1),l(c,y,u.z,v,u.y-1))),4&e&&(l(c,g,u.z,x,u.y),_&&(l(c,h,u.z,u.x,u.y+1),l(c,g,u.z,x,u.y+1))),8&e&&(l(c,y,u.z,v,u.y),_&&(l(c,h,u.z,u.x,u.y+1),l(c,y,u.z,v,u.y+1)));}}const u=[];for(const e of r)r.some(t=>e.isChildOf(t))||u.push(e);if(r=u.filter(i=>!e.some(e=>!!(i.overscaledZ<t&&e.isChildOf(i))||i.equals(e)||i.isChildOf(e))),a){const e=1<<t,i="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),n=[e*i.x,e*i.y],o=4,a=o*o;r=r.filter(e=>{const t=e.canonical.x+.5-n[0],i=e.canonical.y+.5-n[1];return t*t+i*i<a});}return r}extendTileCoverToNearPlane(e,t,i){const n=[],r=new Set;for(const t of e)r.add(t.key);const o=(e,t,i,o,a)=>{const s=op(t,e,i,o,a);r.has(s)||(n.push(new rp(e,t,i,o,a)),r.add(s));},a=e.reduce((e,t)=>Math.max(e,t.overscaledZ),i),s=1<<i,l=[new Pe(0,0),new Pe(Sr,0),new Pe(Sr,Sr),new Pe(0,Sr)],u=new Pe(0,0),c=new Pe(0,0),h=(e,t)=>{const n=Math.floor(e[0]),r=Math.floor(e[1]),h=(e[0]-n)*Sr,d=(e[1]-r)*Sr,f=Math.floor(t[0]),p=Math.floor(t[1]),_=(t[0]-f)*Sr,m=(t[1]-p)*Sr;for(let e=-1;e<=1;e++){const t=n+e;if(!(t<0||t>=s)){u.x=h-e*Sr,c.x=_-(t-f)*Sr;for(let e=-1;e<=1;e++){const n=r+e;u.y=d-e*Sr,c.y=m-(n-p)*Sr,Xh(u,c,l)&&o(a,0,i,t,n);}}}},d=t.points,f=d[3],p=d[2],_=this._projectToGround(f,d[7]),m=this._projectToGround(p,d[6]);return h(f,_),h(p,m),n}_projectToGround(e,t){return X(R(),e,t,e[2]/(e[2]-t[2]))}_projectToZ(e,t,i){const n=e[2]-t[2];return Math.abs(n)<1e-6?P(e):X(R(),e,t,(e[2]-i)/n)}extendTileCoverForTunnels(e,t,i,n){if(i<18)return [];const r=t.points,o=r[0],a=r[1],s=r[4],l=r[5];if(s[2]>=0&&l[2]>=0||o[2]<=0||a[2]<=0)return [];const u=s[2]<0?this._projectToZ(o,s,0):s,c=l[2]<0?this._projectToZ(a,l,0):l,h=-n,d=s[2]<h?this._projectToZ(o,s,h):s,f=l[2]<h?this._projectToZ(a,l,h):l,p=this._findExtensionTilesInQuad(e,i,[f,d,c,u],[.5*(u[0]+c[0]),.5*(u[1]+c[1])]);return p.length>3&&(p.length=3),p}_findExtensionTilesInQuad(e,t,i,n){const r=[],o=new Set;for(const t of e)o.add(t.key);const a=e.reduce((e,t)=>Math.max(e,t.overscaledZ),t),s=1<<t,l=[new Pe(i[0][0],i[0][1]),new Pe(i[1][0],i[1][1]),new Pe(i[3][0],i[3][1]),new Pe(i[2][0],i[2][1]),new Pe(i[0][0],i[0][1])],u=i[0][0],c=i[1][0],h=i[2][0],d=i[3][0],f=i[0][1],p=i[1][1],_=i[2][1],m=i[3][1],g=Math.max(0,Math.floor(Math.min(u,c,h,d))),y=Math.min(s-1,Math.ceil(Math.max(u,c,h,d))-1),x=Math.max(0,Math.floor(Math.min(f,p,_,m))),v=Math.min(s-1,Math.ceil(Math.max(f,p,_,m))-1);for(let e=x;e<=v;e++)for(let i=g;i<=y;i++){if(!qh(l,i,e,i+1,e+1))continue;const n=op(0,a,t,i,e);o.has(n)||(r.push(new rp(a,0,t,i,e)),o.add(n));}const b=n[0],w=n[1];return r.sort((e,t)=>{const i=e.canonical.x+.5-b,n=e.canonical.y+.5-w,r=t.canonical.x+.5-b,o=t.canonical.y+.5-w;return i*i+n*n-(r*r+o*o)||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y}),r}coveringTiles(e){let t=this.coveringZoomLevel(e);const i=t,n=this.elevation&&this.elevation.exaggeration(),r=n&&!e.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==e.minzoom&&t<e.minzoom)return [];void 0!==e.maxzoom&&t>e.maxzoom&&(t=e.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<<t,u=[l*a.x,l*a.y,0],c="globe"===this.projection.name,h=!c,d=Sf.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,h),f=c?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),p=l*yu(1,this.center.lat),_=this._camera.position[2]/yu(1,this.center.lat),m=[l*f.x,l*f.y,_*(h?1:p)],g=c||n,y=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),x=this.isLODDisabled(!0)?t:0;let v;if(this._elevation&&e.isTerrainDEM)v=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();v=e?e.max:this._centerAltitude;}else v=this._centerAltitude;const b=e.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,w=this.projection.isReprojectedInTileSpace?Qg(this):1,E=e=>{const t=1/4e4,i=new Iu(e.x+t,e.y,e.z),n=new Iu(e.x,e.y+t,e.z),r=e.toLngLat(),o=i.toLngLat(),a=n.toLngLat(),s=this.locationCoordinate(r),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=Math.hypot(l.x-s.x,l.y-s.y),h=Math.hypot(u.x-s.x,u.y-s.y);return Math.sqrt(c*h)*w/t},A=e=>{const t=v,i=b;return {aabb:lp(this,l,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},I=[];let T=[];const M=t,S=e.reparseOverscaled?i:t,z=(_-this._centerAltitude)*p,R=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=D(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t<e)return 1;const i=t/e;return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)},D=e=>{if(e.zoom<x)return !0;if(e.zoom===M)return !1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(m),n=e.aabb.distanceY(m);let a=z,l=1;if(c){a=e.aabb.distanceZ(m);const t=Math.pow(2,e.zoom),i=pr((e.y+1)/t),n=pr(e.y/t),r=Math.min(Math.max(s,i),n),o=gu(r)/gu(s);if(l=r===s?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,o/this._mercatorScaleRatio),this.zoom<=5&&e.zoom===M-1&&o>=.9)return !0}else if(r&&(a=e.aabb.distanceZ(m)*p),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=E(new Iu((e.x+.5)/t,(e.y+.5)/t));l=i>.85?1:i;}if(!o&&!c){const i=Math.sqrt(t*t+n*n+a*a);let r=(1<<M-e.zoom)*y*l;return r*=P(Math.max(a,z),i),i<r}let h=Number.MAX_VALUE,d=0;const f=e.aabb.getCorners(),_=[0,0,0];for(const e of f){te(_,e,m),c||(r?_[2]*=p:_[2]=z);const t=W(_,this._camera.forward());t<h&&(h=t,d=Math.abs(_[2]));}let g=(1<<M-e.zoom)*y*l;if(g*=P(Math.max(d,z),h),h<g)return !0;const v=e.aabb.closestPoint(u);return v[0]===u[0]&&v[1]===u[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)I.push(A(-e)),I.push(A(e));for(I.push(A(0));I.length>0;){const i=I.pop(),n=i.x,a=i.y;let s=i.fullyVisible;const h=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!s){let e=g?i.aabb.intersects(d):i.aabb.intersectsFlat(d);if(0===e&&h()){const t=new ip(i.zoom,n,a);e=Nf(this,l,t,!0).intersects(d);}if(0===e)continue;s=2===e;}if(i.zoom===M||!D(i)){const r=i.zoom===M?S:i.zoom;if(e.minzoom&&e.minzoom>r)continue;let o=0;if(!s){let t=g?i.aabb.intersectsPrecise(d):i.aabb.intersectsPreciseFlat(d);if(0===t&&h()){const e=new ip(i.zoom,n,a);t=Nf(this,l,e,!0).intersectsPrecise(d);}if(0===t)continue;if(e.calculateQuadrantVisibility)if(d.containsPoint(i.aabb.center))o=15;else for(let e=0;e<4;e++)0!==i.aabb.quadrant(e).intersects(d)&&(o|=1<<e);}const c=u[0]-(.5+n+(i.wrap<<i.zoom))*(1<<t-i.zoom),f=u[1]-.5-a,p=i.tileID?i.tileID:new rp(r,i.wrap,i.zoom,n,a);e.calculateQuadrantVisibility&&(p.visibleQuadrants=o),T.push({tileID:p,distanceSq:c*c+f*f});continue}for(let e=0;e<4;e++){const t=(n<<1)+e%2,u=(a<<1)+(e>>1),h={aabb:o?i.aabb.quadrant(e):lp(this,l,i.zoom+1,t,u,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:u,wrap:i.wrap,fullyVisible:s,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!c&&(h.tileID=new rp(i.zoom+1===M?S:i.zoom+1,i.wrap,i.zoom+1,t,u),R(h)),I.push(h);}}if(this.fogCullDistSq){const t=this.fogCullDistSq,i=this.horizonLineFromTop();T=T.filter(n=>{const r=[0,0,0,1],o=[Sr,Sr,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());le(r,r,a),le(o,o,a);const s=(h=r,d=o,(c=[])[0]=Math.min(h[0],d[0]),c[1]=Math.min(h[1],d[1]),c[2]=Math.min(h[2],d[2]),c[3]=Math.min(h[3],d[3]),c),l=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e}([],r,o),u=function(e,t){let i=0;for(let n=0;n<2;++n){const r=0;e[n]>r&&(i+=(e[n]-r)*(e[n]-r)),t[n]<r&&(i+=(r-t[n])*(r-t[n]));}return i}(s,l);var c,h,d;if(0===u)return !0;let f=!1;const p=this._elevation;if(p&&u>t&&0!==i){const t=this.calculateProjMatrix(n.tileID.toUnwrapped());let r;e.isTerrainDEM||(r=p.getMinMaxForTile(n.tileID)),r||(r={min:b,max:v});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return Ke[t]}(this.rotation),a=[o[0]*Sr,o[1]*Sr,r.max];Y(a,a,t),f=(1-a[1])*this.height*.5<i;}return u<t||f});}return T.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(e){const t=tt(e.lat,-85.051129,vu),i=this.projection.project(e.lng,t);return new Pe(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/yu(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let i,n;const r=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-r.x)/e,n=(t.y-r.y)/e;}else {const e=this.pointCoordinate(t),o=this.pointCoordinate(r);i=e.x-o.x,n=e.y-o.y;}const o=this.locationCoordinate(e);this.setLocation(new Iu(o.x-i,o.y-n));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(e,t){const i=t?yu(t,e.lat):void 0,n=this.projection.project(e.lng,e.lat);return new Iu(n.x,n.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=t??this._centerAltitude,n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];le(n,n,this.pixelMatrixInverse),le(r,r,this.pixelMatrixInverse);const o=r[3];ae(n,n,1/n[3]),ae(r,r,1/o);const a=n[2],s=r[2];return {p0:n,p1:r,t:a===s?0:(i-a)/(s-a)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return le(t,t,this.pixelMatrixInverse),le(i,i,this.pixelMatrixInverse),ae(t,t,1/t[3]),ae(i,i,1/i[3]),t[2]=yu(t[2],this._center.lat)*this.worldSize,i[2]=yu(i[2],this._center.lat)*this.worldSize,ae(t,t,1/this.worldSize),ae(i,i,1/this.worldSize),new bf([t[0],t[1],t[2]],Z([],te([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:n}=e,r=yu(t[2],this._center.lat),o=yu(i[2],this._center.lat);return new Iu(dn(t[0],i[0],n)/this.worldSize,dn(t[1],i[1],n)/this.worldSize,dn(r,o,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e,t){if(!this.elevation)return this.pointCoordinate(e,t);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new Iu(i[0],i[1],i[2]);let n=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e,t);const o=.02*r,a=e.clone();for(let e=0;e<10&&r-n>o;e++){a.y=dn(n,r,.66);const e=this.projection.pointCoordinate3D(this,a.x,a.y);e?(r=a.y,i=e):n=a.y;}return i?new Iu(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return !1;if(this.elevation||this.zoom>=6)return !this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,n=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return le(n,n,this.pixelMatrix),n[3]>0?new Pe(n[0]/n[3],n[1]/n[3]):new Pe(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,r=this.pointLocation3D(new Pe(t,e)),o=this.pointLocation3D(new Pe(n,e)),a=this.pointLocation3D(new Pe(n,i)),s=this.pointLocation3D(new Pe(t,i));let l=Math.min(r.lng,o.lng,a.lng,s.lng),u=Math.max(r.lng,o.lng,a.lng,s.lng),c=Math.min(r.lat,o.lat,a.lat,s.lat),h=Math.max(r.lat,o.lat,a.lat,s.lat);const f=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,m=(e,t,i,n,r)=>{const o=(e+i)/2,a=(t+n)/2,s=new Pe(o,a),{lng:d,lat:_}=this.pointLocation3D(s),g=Math.max(0,l-d,c-_,d-u,_-h);l=Math.min(l,d),u=Math.max(u,d),c=Math.min(c,_),h=Math.max(h,_),(r<p||g>f)&&(m(e,t,o,a,r+1),m(o,a,i,n,r+1));};if(m(t,e,n,e,1),m(n,e,n,i,1),m(n,i,t,i,1),m(t,i,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=d(new Float64Array(16));_(t,e.pixelMatrix,e.globeMatrix);const i=[0,uu,0],n=[0,cu,0];return Y(i,i,t),Y(n,n,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Jf(e,new _u(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Jf(e,new _u(e.center.lat,-90))]}(this);e?(h=90,u=180,l=-180):t&&(c=-90,u=180,l=-180);}return new mu(new _u(l,c),new _u(u,h))}_getBoundsRectangular(e,t){const{top:i,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,a=new Pe(n,i),s=new Pe(o,i),l=new Pe(o,r),u=new Pe(n,r);let c=this.pointCoordinate(a,e),h=this.pointCoordinate(s,e);const d=this.pointCoordinate(l,t),f=this.pointCoordinate(u,t),p=(e,t)=>(t.y-e.y)/(t.x-e.x);return c.y>1&&h.y>=0?c=new Iu((1-f.y)/p(f,c)+f.x,1):c.y<0&&h.y<=1&&(c=new Iu(-f.y/p(f,c)+f.x,0)),h.y>1&&c.y>=0?h=new Iu((1-d.y)/p(d,h)+d.x,1):h.y<0&&c.y<=1&&(h=new Iu(-d.y/p(d,h)+d.x,0)),(new mu).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-85.051129,this.maxLat=vu,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=hr(this.minLng)*this.tileSize,this.worldMaxX=hr(this.maxLng)*this.tileSize,this.worldMinY=dr(this.maxLat)*this.tileSize,this.worldMaxY=dr(this.minLat)*this.tileSize,this._constrain();}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const n=e.canonical,r=1/this.height,o=this.cameraWorldSize,a=o/this.zoomScale(n.z),s=(n.x+Math.pow(2,n.z)*e.wrap)*a,l=n.y*a,u=this.point;u.x*=o/this.worldSize,u.y*=o/this.worldSize;const c=this.angle,h=Math.sin(-c),d=-Math.cos(-c);return i[t]={bearing:[h,d],center:[(u.x-s)*r,(u.y-l)*r],scale:a/Sr*r},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const n=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return _(n,this.worldToFogMatrix,n),i[t]=new Float32Array(n),i[t]}calculateProjMatrix(e,t=!1,i=!1){const n=e.key;let r;if(r=i?this._expandedProjMatrixCache:t?this._alignedProjMatrixCache:this._projMatrixCache,r[n])return r[n];const o=this.calculatePosMatrix(e,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:t?this.alignedProjMatrix:this.projMatrix,_(o,a,o),r[n]=new Float32Array(o),r[n]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const n=function(e,t){const{scale:i}=e.tileTransform,n=i*Sr/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z)),r=t.inverseAdjustmentMatrix;return new Float32Array([r[0]*n,r[1]*n,r[2]*n,r[3]*n])}(e,this);return i[t]=n,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const e=1/this.worldSize,t=w([],[e,e,e]);return _(t,t,this.globeMatrix),t}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=yu(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),n=this._camera.forward(),r=yu(1,this._center.lat);i[2]/=r,n[2]/=r,Z(n,n);const o=e.raycast(i,n,e.exaggeration());if(o){const e=U([],i,n,o),t=new Iu(e[0],e[1],yu(e[2],pr(e[1]))),a=(t.z+D([t.x-i[0],t.y-i[1],t.z-i[2]*r]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices();}}_constrainCamera(e=!1){if(!this._elevation)return;const t=this._elevation,i=yu(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),r=t.getAtPointOrZero(new Iu(...n)),o=this.pixelsPerMeter/this.worldSize*r,a=this._minimumHeightOverTerrain(),s=n[2]-o;if(s<=a)if(s<0||e){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[n[0],n[1],e.z-n[2]],i=D(t);t[2]-=(a-s)/this._pixelsPerMercatorPixel;const r=D(t);if(0===r)return;k(t,t,i/r*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],e.z*this._pixelsPerMercatorPixel-t[2]],this._updateStateFromCamera();}else this._isCameraConstrained=!0;}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const t=this.center;return t.lat=tt(t.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(t.lng=tt(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:n}=this.point;let r=0,o=i,a=n;const s=this.width/2,l=this.height/2,u=this.worldMinY*this.scale,c=this.worldMaxY*this.scale;if(n-l<u&&(a=u+l),n+l>c&&(a=c-l),c-u<this.height&&(r=Math.max(r,this.height/(c-u)),a=(c+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,n=this.worldSize/2-(e+t)/2;o=(i+n+this.worldSize)%this.worldSize-n,o-s<e&&(o=e+s),o+s>t&&(o=t-s),t-e<this.width&&(r=Math.max(r,this.width/(t-e)),o=(t+e)/2);}o===i&&a===n||this._allowWorldUnderZoom||(this.center=this.unproject(new Pe(o,a))),r&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(r)),this._constrainCamera(),this._unmodified=t,this._constraining=!1;}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t="globe"===this.projection.name,i=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=yu(1,this.center.lat)/yu(1,45));const n=ey(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r="meters"===this.projection.zAxisUnit?i:1,a=this._camera.getWorldToCamera(this.worldSize,r);let s;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-e.x/this.width,l[9]=2*e.y/this.height,this.isOrthographic){let t=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),i=t*this.aspect,n=-i,r=-t;i-=e.x,n-=e.x,t+=e.y,r+=e.y,s=this._camera.getCameraToClipOrthographic(n,i,r,t,this._nearZ+this._nearClipOffset,this._farZ),((e,t,i,n)=>{for(let r=0;r<16;r++)e[r]=dn(t[r],i[r],n);})(s,s,l,Rt(this.pitch>=yw?1:this.pitch/yw));}else s=l;const u=z([],l,a),c=z([],s,a);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center);d(this._mat4Scratch);const t=this._mat4Scratch;m(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),_(t,t,Kg(this)),m(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),_(c,c,t),_(u,u,t),this.inverseAdjustmentMatrix=function(e){const t=Kg(e,!0);return o([],[t[0],t[1],t[4],t[5]])}(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(g(this.mercatorMatrix,c,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=c,p(this.invProjMatrix,this.projMatrix),t){const t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=2*-e.x/this.width,t[9]=2*e.y/this.height,z(this._expandedFarZProjMatrixBuf,t,a),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf;}else this.expandedFarZProjMatrix=this.projMatrix;p(this._mat4Scratch,s),this.frustumCorners=wf.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=Sf.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t),w(this.skyboxMatrix,[1,-1,1]),y(this.skyboxMatrix,this.skyboxMatrix,this._pitch),v(this.skyboxMatrix,this.skyboxMatrix,this.angle),M(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;h(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-e.x/this.width,this._mat4Scratch[9]=2*(e.y+f)/this.height,_(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const x=this.point,b=x.x,E=x.y,A=this.width%2/2,I=this.height%2/2,T=Math.cos(this.angle),S=Math.sin(this.angle),R=b-Math.round(b)+T*A+S*I,P=E-Math.round(E)+T*I+S*A;if(h(this.alignedProjMatrix,c),m(this.alignedProjMatrix,this.alignedProjMatrix,[R>.5?R-1:R,P>.5?P-1:P,0]),w(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),m(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),w(this.glCoordMatrix,[1,-1,1]),m(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),g(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),_(this.pixelMatrix,this.labelPlaneMatrix,u),this._calcFogMatrices(),this._distanceTileDataCache={},!p(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if("globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return qf(t,i,e.worldSize,n,r)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Y(e,e,a),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,r=[e,e,t];k(r,r,n),k(i,i,-1),B(i,i,r),b(this.mercatorFogMatrix,i),g(this.mercatorFogMatrix,this.mercatorFogMatrix,r),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,n);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],n=e[2];let r=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(r=Math.min((t-i)/n,1)),this._camera.position=U([],this._camera.position,e,r),this._updateStateFromCamera();}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:n}=this._camera.getPitchBearing(),r=yu(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(Ye(this._maxPitch)),a=Math.max((e[2]-r)/Math.cos(i),o),s=this._zoomFromMercatorZ(a);U(e,e,t,a),this._pitch=tt(i,Ye(this.minPitch),Ye(this.maxPitch)),this.angle=nt(n,-Math.PI,Math.PI),this._setZoom(tt(s,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new Iu(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(this._seaLevelZoom??this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(e){let t=0,i=6,n=0,r=1/0;for(;i-t>1e-6&&i>t;){const o=t+.5*(i-t),a=this.tileSize*Math.pow(2,o),s=this.getCameraToCenterDistance(this.projection,o,a),l=this.scaleZoom(s/(Math.max(0,e)*this.tileSize)),u=Math.abs(o-l);u<r&&(r=u,n=o),o<l?t=o:i=o;}return n}_terrainEnabled(){return !(!this._elevation||!this.projection.supportsTerrain&&(mt("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),n=Math.max(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(r<this.horizonLineFromTop(!1))return !0;if("mercator"!==this.projection.name)return !1;const a=[new Pe(i,r),new Pe(n,o),new Pe(i,o),new Pe(n,r)],s=this.renderWorldCopies?-3:0,l=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return !0;const i=this.rayIntersectionCoordinate(t);if(i.x<s||i.y<0||i.x>l||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+Je(this.fovAboveCenter)>88||this.anyCornerOffEdge(new Pe(0,0),new Pe(this.width,this.height))}zoomDeltaToMovement(e,t){const i=D(te([],this._camera.position,e)),n=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,i],n){const r=[e,t,i,1];le(r,r,n);const o=r[3]=Math.max(r[3],1e-6);return r[0]/=o,r[1]/=o,r[2]/=o,r}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new Pe(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new Pe(0,e))}}getCameraToCenterDistance(e,t=this.zoom,i=this.worldSize){const n=ey(e,t,this.width,this.height,1024),r=e.pixelSpaceConversion(this.center.lat,i,n);let o=.5/Math.tan(.5*this._fov)*this.height*r;return this.isOrthographic&&(o=dn(1,o,Rt(this.pitch>=yw?1:this.pitch/yw))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&_(e,e,this.globeMatrix),e}getFrustum(e){return Sf.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}const vw=(e,t)=>{if(t<=0||e.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const i=e.transform,n=i.pitch,r=i.isLODDisabled(!1)?60:30;if(n<r-15)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=i._farZ-i._nearZ,a=t*i.height*1.3,s=Math.pow(2,.85*Math.max(i._zoom-e.minCutoffZoom,0)),l=1.4*i.cameraToCenterDistance*s,u=it(r-15,r,n),c=dn(i._farZ+a,l,u),h=Math.min(a,c-i._nearZ);return {shouldRenderCutoff:u>0,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(c-i._nearZ)/o,(c-h-i._nearZ)/o]}}},bw=.05;function ww(e,t,i){const n=it(45,65,i),[r,o]=e.range;let a=1-Math.min(1,Math.exp((t-r)/(o-r)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*n*e.alpha}function Ew(e,t,i,n,r){return ww(e,D(Y([],[t,i,n],r.mercatorFogMatrix)),r.pitch)}function Aw(e,t,i,n){const r=1<<e.z;t.lat=pr((n/Sr+e.y)/r),t.lng=fr((i/Sr+e.x)/r);}const Iw=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Tw=new Float64Array(16),Mw=new Float64Array(16),Sw=new Float64Array(16),zw=new Float64Array(16),Rw=new Float64Array(16),Pw=new Float64Array(16),Dw=new Float64Array(16),Cw=[0,0,0],Fw=new Float32Array(16),Ow=[0,0,0],Lw=[0,0,0],Bw=[];function Nw(e,t,i){const n=i.cameraWorldSizeForFog/i.worldSize;return g(e,i.worldToFogMatrix,[n,n,1]),_(e,e,t),e}function Vw(e,t,i,n){return m(e,t,i),ee(n,cy)||g(e,e,n),e}function kw(e,t,i,n,r){const o=i.material,a=n.context,{baseColorTexture:s,metallicRoughnessTexture:l}=o.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:c,emissionTexture:h}=o;function d(t,i,n){if(t&&(e.push(i),a.activeTexture.set(a.gl.TEXTURE0+n),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:n,wrapT:r}=t.sampler;t.gfxTexture.bindExtraParam(e,i,n,r);}}d(s,"HAS_TEXTURE_u_baseColorTexture",Nb.BaseColor),d(l,"HAS_TEXTURE_u_metallicRoughnessTexture",Nb.MetallicRoughness),d(u,"HAS_TEXTURE_u_normalTexture",Nb.Normal),d(c,"HAS_TEXTURE_u_occlusionTexture",Nb.Occlusion),d(h,"HAS_TEXTURE_u_emissionTexture",Nb.Emission),r&&(r.texture||(r.texture=new __(n.context,r.image,[r.image.height,r.image.height,r.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+Nb.LUT),r.texture&&r.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),e.push("APPLY_LUT_ON_GPU")),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==o.alphaMode&&"MASK"!==o.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),o.defined||e.push("DIFFUSE_SHADED");const f=n.shadowRenderer;f&&(e.push("RENDER_SHADOWS"),f.useNormalOffset&&e.push("NORMAL_OFFSET"));}function Uw(e,t,i,n,r,o){const a=e.modelOpacity,s=t.context,l=new qb(t.context.gl.LEQUAL,e.isLightMesh?qb.ReadOnly:qb.ReadWrite,t.depthRangeFor3D),u=t.transform,c=e.mesh,h=c.material,d=h.pbrMetallicRoughness,m=t.style.fog;"pixels"===t.transform.projection.zAxisUnit?Tw.set(e.nodeModelMatrix):_(Tw,n.zScaleMatrix,e.nodeModelMatrix),_(Tw,n.negCameraPosMatrix,Tw),p(Mw,Tw),f(Mw,Mw);const g="none"===i.paint.get("model-color-use-theme").constantOr("default"),y=i.paint.get("model-emissive-strength").constantOr(0),x={defines:[]},v=[],b=t.shadowRenderer;b&&(b.useNormalOffset=!1),kw(x.defines,v,c,t,g?null:i.lut);let w=null;if(m&&(w=Nw(Sw,e.nodeModelMatrix,t.transform),"globe"!==u.projection.name)){const e=c.aabb.min,t=c.aabb.max,[i,n]=m.getOpacityForBounds(w,e[0],e[1],t[0],t[1]);x.overrideFog=i>=bw||n>=bw;}const E=vw(t,i.paint.get("model-cutoff-fade-range"));E.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const A=t.getOrCreateProgram("model",x),I=Ub(e.worldViewProjection,Tw,Mw,null,t,a,d.baseColorFactor,h.emissiveFactor,d.metallicFactor,d.roughnessFactor,h,y,i,void 0,void 0,e.materialOverride,e.modelColor,1,A.fixedDefines.includes("LIGHTING_3D_MODE"));t.uploadCommonUniforms(s,A,null,w,E,e.lightOverrides),"shadow"!==t.renderPass&&b&&b.setupShadowsFromMatrix(e.nodeModelMatrix,A),A.draw(t,s.gl.TRIANGLES,l,r,o,c.material.doubleSided?Jb.disabled:Jb.backCCW,I,i.id,c.vertexBuffer,c.indexBuffer,c.segments,i.paint,t.transform.zoom,void 0,v);}function Gw(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function jw(e,t,i,n,r,o,a,s,l,u,c){const h=e.transform,d=!!t.isGeometryBloom&&t.isGeometryBloom;if(void 0!==t.minZoom&&e.transform.zoom<t.minZoom)return;if(void 0!==t.maxZoom&&e.transform.zoom>t.maxZoom)return;if(d&&"shadow"===e.renderPass)return;const f="globe"===h.projection.name?sy(i,h):[...i];_(f,f,t.globalMatrix);const p=_([],n,f);if(t.meshes)for(const e of t.meshes){const n=s.get(e.material.name);if(n&&n.opacity<=0)continue;if("BLEND"!==e.material.alphaMode){a.push({mesh:e,depth:0,modelIndex:r,worldViewProjection:p,nodeModelMatrix:f,isLightMesh:d,materialOverride:n,modelOpacity:l,modelColor:u,lightOverrides:c,node:t,modelMatrix:i});continue}const _=Y([],e.centroid,p);!h.isOrthographic&&_[2]<=0||o.push({mesh:e,depth:_[2],modelIndex:r,worldViewProjection:p,nodeModelMatrix:f,isLightMesh:d,materialOverride:n,modelOpacity:l,modelColor:u,lightOverrides:c,node:t,modelMatrix:i});}if(t.children)for(const h of t.children)jw(e,h,i,n,r,o,a,s,l,u,c);}function Hw(e,t,i,n,r){const o=i.shadowRenderer;if(!o)return;const a=o.getShadowPassDepthMode(),s=r||o.calculateShadowPassMatrixFromMatrix(t),l=Gb(s);i.getOrCreateProgram("modelDepth").draw(i,i.context.gl.TRIANGLES,a,Hb.disabled,Wb.disabled,Jb.disabled,l,n.id,e.vertexBuffer,e.indexBuffer,e.segments,n.paint,i.transform.zoom,void 0,void 0);}function $w(e,t,i,n){const r=function(e,t){if(t.footprintDebugMesh)return t.footprintDebugMesh;if(!t.footprint)return null;const i=e.context,n=t.footprint.vertices,r=t.footprint.indices,o=new Uu;o.reserve(n.length);for(const e of n)o.emplaceBack(e.x,e.y);const a=new uc;a.reserve(r.length);for(let e=0;e<r.length;e+=3)a.emplaceBack(r[e],r[e+1],r[e+2]);const s=i.createVertexBuffer(o,xf.members),l=i.createIndexBuffer(a),u=Uc.simpleSegment(0,0,n.length,r.length),c=t.id||t.name||"footprint";let h;const d=parseInt(c,10);h=isNaN(d)?function(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return t}(c):d;const f=Pt(h),p=Pt(h+1),_=Pt(h+2);return t.footprintDebugMesh={vertexBuffer:s,indexBuffer:l,segments:u,color:new pn(f,p,_,.5)},t.footprintDebugMesh}(e,i);if(!r)return;const o=e.context,a=o.gl,s=e.getOrCreateProgram("debug"),l=r.color,u=qb.disabled;o.activeTexture.set(a.TEXTURE0),e.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s.draw(e,a.TRIANGLES,u,Hb.disabled,Wb.alphaBlended,Jb.disabled,Iw(n,l.toPremultipliedRenderColor(null)),"$debug",r.vertexBuffer,r.indexBuffer,r.segments);}function Zw(e,t,i,n,r,o){for(const a of r){const r={...n};r.part=a;const s={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(s,i)};o.set(a,l);}}function Ww(e,t,i,n,r,o){for(const a of r){const r={...n};r.part=a;const s={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(s,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(s,i),opacity:e.paint.get("model-opacity").evaluate(s,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(s,i)};o.set(a,l);}}function qw(e,t,i,n,r){let o=!1;for(const i of n)1!==i.modelOpacity&&(Uw(i,e,t,r[i.modelIndex],Hb.disabled,Wb.disabled),o=!0);for(const i of n)Uw(i,e,t,r[i.modelIndex],1!==i.modelOpacity?e.stencilModeFor3D():Hb.disabled,e.colorModeForRenderPass());o&&e.resetStencilClippingMasks();const a=Wb.additive;for(const n of i)Uw(n,e,t,r[n.modelIndex],Hb.disabled,n.isLightMesh?a:e.colorModeForRenderPass());}function Xw(e,t,i){const n=t.updateZoomBasedPaintProperties(),r=function(e,t,i){let n,r,o,a=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&a>0){const t=e.terrain,r=t.findDEMTileFor(i);r&&r.dem?n=vb.create(t,i,r):a=0;}if(0===a&&(t.terrainElevationMin=0,t.terrainElevationMax=0),a===t.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===t.validForDEMTile.id&&n._dem._timestamp===t.validForDEMTile.timestamp))return !1;for(const e in t.instancesPerModel){const i=t.instancesPerModel[e];for(let e=0;e<i.instancedDataArray.length;++e){const s=(n?a*n.getElevationAt(0|i.instancedDataArray.float32[16*e],0|i.instancedDataArray.float32[16*e+1],!0,!0):0)+i.instancesEvaluatedElevation[e];i.instancedDataArray.float32[16*e+6]=s,r=r?Math.min(t.terrainElevationMin,s):s,o=o?Math.max(t.terrainElevationMax,s):s;}}return t.terrainElevationMin=r||0,t.terrainElevationMax=o||0,t.validForExaggeration=a,t.validForDEMTile=n&&n._demTile?{id:n._demTile.tileID,timestamp:n._dem._timestamp}:{id:void 0,timestamp:0},!0}(e,t,i);(n||r)&&(t.uploaded=!1,t.upload(e.context));}const Yw={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new zf([0,0,0],[Sr,Sr,0])};function Jw(e,t){const i=1<<e.canonical.z,n=t.getFreeCameraOptions().position,r=t.elevation,o=e.canonical.x/i,a=(e.canonical.x+1)/i,s=e.canonical.y/i,l=(e.canonical.y+1)/i;let u=t._centerAltitude;if(r){const t=r.getMinMaxForTile(e);t&&t.max>u&&(u=t.max);}const c=tt(n.x,o,a)-n.x,h=tt(n.y,s,l)-n.y,d=yu(u,t.center.lat)-n.z;return t._zoomFromMercatorZ(Math.sqrt(c*c+h*h+d*d))}function Kw(e,t,i,n,r,o,a){const s=e.context,l="shadow"===e.renderPass,u=e.shadowRenderer,c=l&&u?u.getShadowPassDepthMode():new qb(s.gl.LEQUAL,qb.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const f of i.meshes){const p=d?[]:["MODEL_POSITION_ON_GPU"],_=[];let m,g,y;const x=!d&&n.instancedDataArray.length>20;x&&p.push("INSTANCED_ARRAYS");const v=vw(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&u)m=e.getOrCreateProgram("modelDepth",{defines:p}),g=Gb(a.shadowTileMatrix,a.shadowTileMatrix,i.globalMatrix),y=Wb.disabled;else {kw(p,_,f,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:p,overrideFog:h});const n=f.material,l=n.pbrMetallicRoughness,c=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);g=Ub(o.expandedProjMatrix,i.globalMatrix,Fw,null,e,c,l.baseColorFactor,n.emissiveFactor,l.metallicFactor,l.roughnessFactor,n,d,t,r,void 0,void 0,void 0,1,m.fixedDefines.includes("LIGHTING_3D_MODE")),u&&(a.shadowUniformsInitialized?m.setShadowUniformValues(s,u.getShadowUniformValues()):(u.setupShadows(o.toUnwrapped(),m,"model-tile"),a.shadowUniformsInitialized=!0)),y=v.shouldRenderCutoff||c<1||"OPAQUE"!==n.alphaMode?Wb.alphaBlended:Wb.unblended;}e.uploadCommonUniforms(s,m,o.toUnwrapped(),null,v);const b=f.material.doubleSided?Jb.disabled:Jb.backCCW;if(x)_.push(n.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,c,Hb.disabled,y,b,g,t.id,f.vertexBuffer,f.indexBuffer,f.segments,t.paint,e.transform.zoom,void 0,_,n.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;r<n.instancedDataArray.length;++r)g[i]=new Float32Array(n.instancedDataArray.arrayBuffer,64*r,16),m.draw(e,s.gl.TRIANGLES,c,Hb.disabled,y,b,g,t.id,f.vertexBuffer,f.indexBuffer,f.segments,t.paint,e.transform.zoom,void 0,_);}}if(i.children)for(const s of i.children)Kw(e,t,s,n,r,o,a);}function Qw(e,t,i,n,r){const o=e.node;if(o.lodMeshes&&o.lodMeshes.length>0)if(e.targetLod<0)e.targetLod=t>n?1:0;else {const o=r>0?i/1e3/r:1;e.targetLod=tt(t>n?e.targetLod+o:e.targetLod-o,0,1);}else e.targetLod=0;}function eE(e,t,i,n){if(!i.modelManager)return !0;const r=i.modelManager;if(!i.shadowRenderer)return !0;const o=i.shadowRenderer,a=t.aabb;let s=!0,l=e.maxHeight;if(0===l){let t=0;for(const i in e.instancesPerModel){const e=r.getModel(i,n);e?t=Math.max(t,Math.max(Math.max(e.aabb.max[0],e.aabb.max[1]),e.aabb.max[2])):s=!1;}l=e.maxScale*t*1.41+e.maxVerticalOffset,s&&(e.maxHeight=l);}a.max[2]=l,a.min[2]+=e.terrainElevationMin,a.max[2]+=e.terrainElevationMax,Y(a.min,a.min,t.tileMatrix),Y(a.max,a.max,t.tileMatrix);const u=a.intersects(o.getCurrentCascadeFrustum());return 0===i.currentShadowCascade&&(e.isInsideFirstShadowMapFrustum=2===u),0===u}function tE(e,t){const i=e.uniformValues.u_cutoff_params[0],n=e.uniformValues.u_cutoff_params[1],r=e.uniformValues.u_cutoff_params[2],o=e.uniformValues.u_cutoff_params[3];return n===i||o===r?1:tt(((t-i)/(n-i)-r)/(o-r),0,1)}function iE(e,t,i,n){if(t.pitch<20)return 1;const r=t.getWorldToCameraMatrix();_(r,r,e);const o=oe(i.min[0],i.min[1],i.min[2],1);let a=le(re(),o,r),s=a,l=a;o[1]=i.max[1],a=le(re(),o,r),s=a[1]<s[1]?a:s,l=a[1]>l[1]?a:l,o[0]=i.max[0],a=le(re(),o,r),s=a[1]<s[1]?a:s,l=a[1]>l[1]?a:l,o[1]=i.min[1],a=le(re(),o,r),s=a[1]<s[1]?a:s,l=a[1]>l[1]?a:l;const u=tt(n[0],0,1),c=100*t.pixelsPerMeter*tt(n[1],0,1),h=tt(n[2],0,1),d=(m=re(),b=(g=s)[1],w=g[2],E=g[3],m[0]=(v=g[0])+(x=u)*((y=l)[0]-v),m[1]=b+x*(y[1]-b),m[2]=w+x*(y[2]-w),m[3]=E+x*(y[3]-E),m),f=Math.tan(.5*t.fovX),p=-d[2]*f;var m,g,y,x,v,b,w,E;if(0===c)return d[1]<-Math.abs(p)?h:1;const A=tt(dn(1,h,(-Math.abs(p)-d[1])/c),h,1);return dn(1,A,tt((t.pitch-20)/20,0,1))}var nE="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",rE="\n#if defined(VIEWPORT_ORIGIN_TOP_LEFT) || defined(FLIP_Y)\n#define FLIP_VIEWPORT_UV_Y(uv) (uv).y=1.0-(uv).y\n#else\n#define FLIP_VIEWPORT_UV_Y(uv)\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp float depth=ndc_z;\n#else\nhighp float depth=ndc_z*0.5+0.5;\n#endif\nconst highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}const float DITHER_THRESHOLDS[16]=float[16](\n1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);int viewport_dither_index(vec2 fragCoordXY) {return (int(fragCoordXY.x) % 4)*4+(int(fragCoordXY.y) % 4);}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}",oE="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",aE="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",sE="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;\n#endif\nvec3 elevationVector(vec2 pos) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;\n#else\nreturn vec3(0,0,1);\n#endif\n}\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#endif\nfloat elevation(vec2 apos) {\n#ifdef TERRAIN\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);\n#else\nreturn currentElevation(apos);\n#endif\n#else\nreturn 0.0;\n#endif\n}\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",lE="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",uE="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",cE="\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif",hE="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",dE="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",fE="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp vec2 shadow_map_ndc_to_uv(highp vec2 ndc_xy) {\n#ifdef SHADOW_MAP_FLIP_Y\nreturn ndc_xy*vec2(0.5,-0.5)+0.5;\n#else\nreturn ndc_xy*0.5+0.5;\n#endif\n}highp vec3 shadow_map_ndc_to_sample_space(highp vec3 ndc) {\n#ifdef CLIP_ZERO_TO_ONE\nreturn vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z);\n#else\nreturn vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z*0.5+0.5);\n#endif\n}float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z-bias);\n#else\nhighp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=shadow_map_ndc_to_sample_space(light_view_pos0.xyz/light_view_pos0.w);highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const pE=/^#include\s+"([^"]+)"\s*\r?\n/gm,_E=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,mE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,gE=new Set(["ifdef","ifndef","elif","if","defined"]),yE=new Set;SE(nE,yE),SE(oE,yE),SE(rE,yE);const xE={"_prelude_fog.vertex.glsl":lE,"_prelude_terrain.vertex.glsl":sE,"_prelude_shadow.vertex.glsl":dE,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":uE,"_prelude_shadow.fragment.glsl":fE,"_prelude_lighting.glsl":cE,"_prelude_raster_array.glsl":hE,"_prelude_indicator_cutout.fragment.glsl":"\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);\n#else\nreturn 1.0;\n#endif\n}","_prelude_feature_cutout.fragment.glsl":"// feature cutout (gl-native only)\n","_prelude_feature_cutout.vertex.glsl":"// feature cutout (gl-native only)\n"},vE={},bE="precision highp float;",wE="precision mediump float;",EE="\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif",AE={preludeTerrain:RE("",sE),preludeFog:RE(uE,lE),preludeShadow:RE(fE,dE),preludeRasterArray:RE(hE,""),preludeLighting:RE(cE,cE),preludePrecisionQualifiers:RE(wE,bE),prelude:RE(rE,oE),preludeExtensions:RE(EE,"")},IE=[EE,wE,nE,AE.prelude.fragmentSource].join("\n"),TE=[bE,nE,AE.prelude.vertexSource].join("\n");var ME={background:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef FEATURE_CUTOUT\nvec2 uv=fragcoord_to_viewport_uv(gl_FragCoord.xy,u_inv_viewport_size.xy);float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),circle:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin 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\nuniform float u_emissive_strength;void 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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout 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\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void 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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:RE("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:RE('#include "_prelude_fog.fragment.glsl"\nuniform 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);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout 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() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.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 tilePos=floor(vec2(a_pos)*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:RE("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));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:RE("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}'),collisionCircle:RE("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:RE("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),fill:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp 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);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:RE("uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;\n#define ADDITIVE 1\nvoid main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:RE("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nuniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);\n#endif\n#endif\n}'),fillExtrusionPattern:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),hillshadePrepare:RE("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos.y=1.0-v_pos.y;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform highp float u_floor_width_scale;in highp vec2 v_tex;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 v_elevation_id_col;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec3 v_uv;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef RENDER_LINE_BORDER_GRADIENT\nuniform sampler2D u_border_gradient_image;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nuniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform bool u_emissive_in_shadows;uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);float pxStep;float delta;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\npxStep=fwidth(dist);float out_edge=v_width2_dilute.x-dist;float in_edge=dist-(v_width2_dilute.y-2.0*ANTIALIASING);delta=v_width2_dilute.y > 0.0 ? min(in_edge,out_edge) : out_edge;float edge=ANTIALIASING;alpha=delta > 0.0 ? smoothstep(edge-pxStep,u_width_scale*blur+edge+pxStep,delta) : 0.0;\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nhighp float dash_w=float(dash.w);highp float dash_len=float(dash.z)+dash_w/65535.0;float sdfgamma=ANTIALIASING/float(dash_len);float scaled_floorwidth=(floorwidth*u_floor_width_scale);float periods_per_pixel=fwidth(v_tex.x);float dash_coverage=float(dash.y >> 4u)/4095.0;float fade=linearstep(0.25,0.5,periods_per_pixel);float gamma=max(sdfgamma/scaled_floorwidth,0.5*periods_per_pixel);if (fade >=1.0) {alpha*=dash_coverage;} else if (periods_per_pixel < 0.1) {float sdfdist=texture(u_dash_image,v_tex).r;alpha*=linearstep(0.5-gamma,0.5+gamma,sdfdist);} else {float span=min(periods_per_pixel,1.0);float tap_offset=span*0.25;float sdf0=texture(u_dash_image,vec2(v_tex.x-tap_offset,v_tex.y)).r;float sdf1=texture(u_dash_image,vec2(v_tex.x+tap_offset,v_tex.y)).r;alpha*=mix(0.5*(\nlinearstep(0.5-gamma,0.5+gamma,sdf0)+linearstep(0.5-gamma,0.5+gamma,sdf1)\n),dash_coverage,fade);}\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {\n#ifdef RENDER_LINE_BORDER_GRADIENT\nvec4 border_gradient_color=texture(u_border_gradient_image,v_uv.xy);out_color=mix(border_gradient_color*trim_alpha,out_color,alpha2);\n#else\nif (border_color.a==0.0) {\n#ifndef RENDER_LINE_GRADIENT\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-alpha2));} else {out_color.rgb*=(0.6+0.4*alpha2);}\n#else\nout_color.rgb*=(0.6+0.4*alpha2);\n#endif\n} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}\n#endif\nout_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef LINE_BLEND_ADDITIVE\n{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}\n#else\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);\n#else\nglFragColor=out_color;\n#endif\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef DEBUG_ELEVATION_ID\nglFragColor=vec4(v_elevation_id_col,1.0);\n#endif\nif (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)\nin vec4 a_z_offset_width;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 a_elevation_id_col;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nout vec3 v_elevation_id_col;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_z_offset;uniform highp float u_road_view_depth_bias;uniform highp vec4 u_road_clip_to_view;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform highp float u_floor_width_scale;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out highp vec2 v_tex;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nout highp vec3 v_uv;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT)\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\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 mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\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 mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\n#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH\nemissive_strength=a_z_offset_width.w;\n#endif\nfloat a_z_offset=u_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset+=a_z_offset_width.x;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nv_elevation_id_col=a_elevation_id_col;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\nvec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=u_width_scale*(left ? left_width : right_width);if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=apply;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;symmetric_outset=zero_right_width ? u_width_scale*left_width : halfwidth;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth > 0.0 ? ANTIALIASING : 0.0);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\nv_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\nv_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\nv_tile_pos=(v_tile_pos+extrude)/EXTENT;\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#ifdef VARIABLE_LINE_WIDTH\n#ifndef ELEVATED\nif (u_road_view_depth_bias > 0.0) {highp float z_in=gl_Position.z/gl_Position.w*0.5+0.5;highp float a=u_road_clip_to_view.x;highp float b=u_road_clip_to_view.y;highp float c=u_road_clip_to_view.z;highp float d=u_road_clip_to_view.w;highp float view=(a*z_in+b)/(c*z_in+d);highp float view_new=view+u_road_view_depth_bias;highp float z_new=(view_new*d-b)/(a-view_new*c);z_new=clamp(z_new,0.0,1.0);gl_Position.z=(z_new*2.0-1.0)*gl_Position.w;}\n#endif\n#endif\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT)\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);highp float dash_w=float(dash.w);highp float totalLength=float(dash.z)+dash_w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;float dash_half_height=float(dash.y & 15u);v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dash_half_height+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef VARIABLE_LINE_WIDTH\nv_width2_dilute.x=symmetric_outset;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec4 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;uniform highp float u_color_ramp_size;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#ifdef RASTER_COLOR_SCALE_LOG\nfloat N=u_color_ramp_size;float vNorm=max((value.x-0.5/N)*N/(N-1.0),0.0);vNorm=log(vNorm*(10.0-1.0)+1.0)/log(10.0);value.x=0.5/N+vNorm*(N-1.0)/N;\n#endif\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nfloat tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbol:RE('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform sampler2D u_texture_icon;\n#endif\nuniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_sdf;uniform lowp float u_scale_factor;uniform lowp float u_opacity_multiplier;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin lowp float v_opacity;in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\nvoid main() {lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;if (u_is_sdf) {fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;}lowp float emissive_strength=0.0;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nif (u_is_sdf) {float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;} else {\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n}out_color*=opacity*fade_opacity*u_opacity_multiplier;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,0.0);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\n#endif\nuniform 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_matrix;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_inv_matrix;\n#endif\nuniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_up_vector;\n#endif\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform vec2 u_texsize_icon;\n#endif\nuniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;uniform highp float u_spp_zoom_fraction;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nfloat zoomFactor(float zm,float zM) {if (zm==zM) return u_spp_zoom_fraction-zm >=0.0 ? 1.0 : 0.0;return clamp((u_spp_zoom_fraction-zm)/(zM-zm),0.0,1.0);}vec4 readColor(uint base,bool isDataDriven,uint offsetVec4,uint dzr,vec2 headerZoom,vec4 fallbackValue) {if (!isDataDriven) return fallbackValue;vec4 value=u_spp_properties.properties[base+offsetVec4];vec2 blockZoom=u_spp_properties.properties[base+offsetVec4+dzr].xy;vec2 zr=mix(headerZoom,blockZoom,float(dzr));return unpack_mix_color(value,zoomFactor(zr.x,zr.y));}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float readScalar(uint base,bool isDataDriven,uint offsetVec4,float fallbackValue) {if (!isDataDriven) return fallbackValue;vec4 slot=u_spp_properties.properties[base+offsetVec4];return unpack_mix_vec2(slot.xy,zoomFactor(slot.z,slot.w));}vec2 readTranslate(uint base,bool isDataDriven,uint offsetVec4,uint dzr) {if (!isDataDriven) return vec2(0.0);vec4 value=u_spp_properties.properties[base+offsetVec4];vec2 blockZoom=u_spp_properties.properties[base+offsetVec4+dzr].xy;float t=zoomFactor(blockZoom.x,blockZoom.y)*float(dzr);return mix(value.xy,value.zw,t);}SymbolPaintProperties readSymbolPaintProperties() {uint dataDrivenMask=u_spp_header.header[0][0];uint dzrMask =u_spp_header.header[0][1];uint blockSizeVec4 =u_spp_header.header[0][2];uint fillColorDzr=dzrMask & 1u;uint haloColorDzr=(dzrMask >> 1u) & 1u;vec2 fillColorHeaderZoom=uintBitsToFloat(u_spp_header.header[3].xy);vec2 haloColorHeaderZoom=uintBitsToFloat(u_spp_header.header[3].zw);uint featureIndex=uint(a_feature_index);uvec4 indexSlot=u_spp_index.block_indices[featureIndex/4u];uint base=uvec4At(indexSlot,featureIndex % 4u)*blockSizeVec4;SymbolPaintProperties props;props.fill_np_color =readColor(base,(dataDrivenMask & (1u << 0u)) !=0u,u_spp_header.header[0][3],fillColorDzr,fillColorHeaderZoom,u_spp_fill_np_color);props.halo_np_color =readColor(base,(dataDrivenMask & (1u << 1u)) !=0u,u_spp_header.header[1][0],haloColorDzr,haloColorHeaderZoom,u_spp_halo_np_color);props.opacity =readScalar(base,(dataDrivenMask & (1u << 2u)) !=0u,u_spp_header.header[1][1],u_spp_opacity);props.halo_width =readScalar(base,(dataDrivenMask & (1u << 3u)) !=0u,u_spp_header.header[1][2],u_spp_halo_width);props.halo_blur =readScalar(base,(dataDrivenMask & (1u << 4u)) !=0u,u_spp_header.header[1][3],u_spp_halo_blur);props.emissive_strength=readScalar(base,(dataDrivenMask & (1u << 5u)) !=0u,u_spp_header.header[2][0],u_spp_emissive_strength);props.occlusion_opacity=readScalar(base,(dataDrivenMask & (1u << 6u)) !=0u,u_spp_header.header[2][1],u_spp_occlusion_opacity);props.z_offset =readScalar(base,(dataDrivenMask & (1u << 7u)) !=0u,u_spp_header.header[2][2],u_spp_z_offset);uint translateDzr=(dzrMask >> 8u) & 1u;props.translate =readTranslate(base,(dataDrivenMask & (1u << 8u)) !=0u,u_spp_header.header[2][3],translateDzr);return props;}vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#endif\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y\n);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\ngl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:RE("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:RE('#include "_prelude_fog.fragment.glsl"\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',aE),skyboxGradient:RE('#include "_prelude_fog.fragment.glsl"\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',aE),skyboxCapture:RE("\nin highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;\n#ifndef VIEWPORT_ORIGIN_TOP_LEFT\nv_position.y*=-1.0;\n#endif\nv_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;\n#ifndef GLOBE_POLES\nuniform mat4 u_merc_matrix;\n#endif\nuniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifndef GLOBE_POLES\nuniform mat3 u_grid_matrix;\n#endif\nuniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\nvec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:RE('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),stars:RE("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),occlusion:RE("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function SE(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(mE);if(i)for(const e of i)gE.has(e)||t.add(e);}}function zE(e){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(e)}function RE(e,t){const i=new Set,n=[],r=[];e=e.replace(pE,(e,t)=>(r.push(t),"")),t=t.replace(pE,(e,t)=>(n.push(t),""));let o=new Set(yE);SE(e,o),SE(t,o);for(const e of [...n,...r])vE[e]||(vE[e]=new Set,SE(xE[e],vE[e])),o=new Set([...o,...vE[e]]);return {fragmentSource:e=e.replace(_E,(e,t,n,r,o)=>(i.add(o),"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\n${zE(r)?"flat ":""}in ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${n} ${r} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(_E,(e,t,n,r,o)=>{const a=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,s="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${s}(a_${o}, materialInfo, ${a})`,u=o.includes("color")?"color":s;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${n} ${r} a_${o};\n#endif\n`:i.has(o)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${a})\n in ${n} ${s} a_${o};\n #endif\n${zE(r)?"flat ":""}out ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"initialize"===t?"vec4"===u||"uvec4"===u?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o})\n #ifdef ${a}\n ${o} = unpack_mix_${u}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${u}(a_${o}, u_${o}_t);\n #endif\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${n} ${r} a_${o};\n out ${n} ${r} ${o};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${o} = a_${o};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${a})\n in ${n} ${s} a_${o};\n #endif\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===u?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${o}0;\nin vec4 a_${o}1;\nin vec4 a_${o}2;\nin vec4 a_${o}3;\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${n} ${s} a_${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${n} ${r} ${o} = a_${o};\n#endif\n`:"vec4"===u||"uvec4"===u?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${a}\n ${n} ${r} ${o} = ${l};\n #else\n ${n} ${r} ${o} = a_${o};\n #endif\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${a}\n ${n} ${r} ${o} = unpack_mix_${u}(${l}, u_${o}_t);\n #else\n ${n} ${r} ${o} = unpack_mix_${u}(a_${o}, u_${o}_t);\n #endif\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`}),usedDefines:o,vertexIncludes:n,fragmentIncludes:r}}var PE={model:RE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;\n#endif\nuniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nin highp float v_cutout_factor;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\ntexColor=vec4(unpremultiplyColor(texColor),1.0);\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir;vec3 lightColor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#else\nlightDir=u_lightpos;lightColor=u_lightcolor;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\napply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);\n#else\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_feature_cutout.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nout highp float v_cutout_factor;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nv_cutout_factor=1.0;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#ifdef FEATURE_CUTOUT_VERTEX\nhighp vec4 ground_pos=vec4(pos_a.xy,0.0,1.0);highp vec4 cutout_clip_pos=mix(u_matrix*ground_pos,AWAY,hidden);highp vec3 cutout_ndc=cutout_clip_pos.xyz/cutout_clip_pos.w;vec2 uv=cutout_ndc.xy*0.5+0.5;highp float fragDepthNDC=cutout_ndc.z*0.5+0.5;\n#ifdef FLIP_Y\nfragDepthNDC=cutout_ndc.z;\n#endif\nhighp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);\n#endif\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:RE("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}"),fillExtrusionDepth:RE("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}'),fillExtrusionGroundEffect:RE("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),groundShadow:RE('#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp float cutoutFactor=get_cutout_factors(gl_FragCoord).y;highp float cutoutDepthNDC=sample_cutout_depth_bilinear(u_cutout_depth_image,uv);highp float fragDepthNDC=gl_FragCoord.z/u_feature_cutout_params.w;highp float groundThreshold=-0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);cutoutFactor=mix(0.0,cutoutFactor,groundLimit);shadow=mix(shadow,vec3(1.0),cutoutFactor);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}')};const DE=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t});function CE(e,t,i=0){const n=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/n,o=r*(t.tileID.canonical.x+t.tileID.wrap*n),a=r*t.tileID.canonical.y;return {u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/Bv(t,1,e.transform.tileZoom),u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a],u_pattern_transition:i}}const FE={terrain:0,flat:1},OE=u(),LE=[0,0,0],BE=(e,t,i,n,r,o,s,u,c,h,d,f,p,_,m,g,y,x,v=[0,0,1],b=!1)=>{let w=LE,E=0,A=LE;if(!b){const e=t.style.light,i=e.properties.get("position");if(w=[i.x,i.y,i.z],"viewport"===e.properties.get("anchor")){const e=a();l(e,-t.transform.angle),J(w,w,e);}const n=e.properties.get("color").toPremultipliedRenderColor(null);E=e.properties.get("intensity"),A=[n.r,n.g,n.b];}const I=t.transform,T={u_matrix:e,u_lightpos:w,u_lightintensity:E,u_lightcolor:A,u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:OE,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:FE[h],u_base_type:FE[d],u_ao:r,u_edge_radius:o,u_width_scale:s,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:y,u_ground_shadow_factor:x,u_front_cutoff_params:v};return "globe"===I.projection.name&&(T.u_tile_id=[u.canonical.x,u.canonical.y,1<<u.canonical.z],T.u_zoom_transition=f,T.u_inv_rot_matrix=_,T.u_merc_center=p,T.u_up_dir=I.projection.upVector(new ip(0,0,0),p[0]*Sr,p[1]*Sr),T.u_height_lift=c),T},NE=new Float32Array(16);function VE(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,g,y,x,v,b){const w=t.context,E=w.gl,A=t.transform,I=t.transform.zoom,T=[],M=e.translate,S=e.translateAnchor,z=e.edgeRadius,R=vw(t,e.cutoffFadeRange);"clear"===c?(T.push("CLEAR_SUBPASS"),v&&(T.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(E.TEXTURE0),v.bind(E.LINEAR,E.CLAMP_TO_EDGE))):"sdf"===c?T.push("SDF_SUBPASS"):"emissive"===c&&(T.push("USE_MRT1"),w.activeTexture.set(E.TEXTURE0),v.bind(E.LINEAR,E.CLAMP_TO_EDGE)),y&&T.push("HAS_CENTROID"),R.shouldRenderCutoff&&T.push("RENDER_CUTOFF");const P=(e,i,r,c,m)=>{let x=T;null!=i.groundRadiusBuffer&&(x=T.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=i.programConfigurations.get(n.id),E=t.isTileAffectedByFog(e),A=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:x,overrideFog:E}),M=((e,t,i,n,r,o,a,s,l,u)=>({u_matrix:e,u_opacity:t,u_ao_pass:i?1:0,u_meter_to_tile:n,u_ao:r,u_flood_light_intensity:o,u_flood_light_color:a,u_attenuation:s,u_edge_radius:l,u_fb:0,u_fb_size:u,u_dynamic_offset:1}))(c,h,u,m,[d,f*m],p,_,g,I>=17?0:z*m,v?v.size[0]:0),S=[];y&&S.push(i.hiddenByLandmarkVertexBuffer),null!=i.groundRadiusBuffer&&S.push(i.groundRadiusBuffer),t.uploadCommonUniforms(w,A,e.toUnwrapped(),null,R),A.draw(t,w.gl.TRIANGLES,o,a,s,l,M,n.id,i.vertexBuffer,i.indexBuffer,r,n.paint,I,b,S);};for(const e of r){const r=i.getTile(e),o=r.getBucket(n);if(!o||o.projection.name!==A.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const a=o.groundEffect,s=1/o.tileToMeter;{const i=t.translatePosMatrix(e.projMatrix,r,M,S),n=a.getDefaultSegment();P(e,a,n,i,s);}if(x)for(let o=0;o<4;o++){const a=ap[o](e),l=i.getTile(a);if(!l)continue;const u=l.getBucket(n);if(!u||u.projection.name!==A.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const c=u.groundEffect;let h,d;0===o?(h=[-8192,0,0],d=1):1===o?(h=[Sr,0,0],d=0):2===o?(h=[0,-8192,0],d=3):(h=[0,Sr,0],d=2);const f=c.regionSegments[d];f&&(m(NE,e.projMatrix,h),P(e,c,f,t.translatePosMatrix(NE,r,M,S),s));}}}const kE={model:e=>({u_matrix:new rh(e),u_lighting_matrix:new rh(e),u_normal_matrix:new rh(e),u_node_matrix:new rh(e),u_lightpos:new eh(e),u_lightintensity:new Kc(e),u_lightcolor:new eh(e),u_camera_pos:new eh(e),u_opacity:new Kc(e),u_baseColorFactor:new ih(e),u_emissiveFactor:new ih(e),u_metallicFactor:new Kc(e),u_roughnessFactor:new Kc(e),u_baseTextureIsAlpha:new Jc(e),u_alphaMask:new Jc(e),u_alphaCutoff:new Kc(e),u_baseColorTexture:new Jc(e),u_metallicRoughnessTexture:new Jc(e),u_normalTexture:new Jc(e),u_occlusionTexture:new Jc(e),u_emissionTexture:new Jc(e),u_lutTexture:new Jc(e),u_color_mix:new ih(e),u_aoIntensity:new Kc(e),u_emissive_strength:new Kc(e),u_occlusionTextureTransform:new ih(e),u_dithered_discard_threshold:new Kc(e)}),modelDepth:e=>({u_matrix:new rh(e),u_instance:new rh(e),u_node_matrix:new rh(e)}),groundShadow:e=>({u_matrix:new rh(e),u_ground_shadow_factor:new eh(e)}),fillExtrusionDepth:e=>({u_matrix:new rh(e),u_edge_radius:new Kc(e),u_width_scale:new Kc(e),u_vertical_scale:new Kc(e),u_height_type:new Jc(e),u_base_type:new Jc(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new rh(e),u_opacity:new Kc(e),u_ao_pass:new Kc(e),u_meter_to_tile:new Kc(e),u_ao:new Qc(e),u_flood_light_intensity:new Kc(e),u_flood_light_color:new eh(e),u_attenuation:new Kc(e),u_edge_radius:new Kc(e),u_fb:new Jc(e),u_fb_size:new Kc(e),u_dynamic_offset:new Kc(e)})};function UE(e){const t=e.properties.get("direction"),i=xt(t.x,t.y,t.z);i[2]=tt(i[2],0,75);const n=yt([i[0],i[1],i[2]]);return C(n.x,n.y,n.z)}function GE(e,t,i){const n="none"===t.properties.get("color-use-theme"),r=t.properties.get("color"),o=t.properties.get("intensity"),a=t.properties.get("direction"),s=[a.x,a.y,a.z],l="none"===i.properties.get("color-use-theme"),u=i.properties.get("color"),c=i.properties.get("intensity"),h=Math.max(W([0,0,1],s),0),d=[0,0,0];k(d,u.toPremultipliedRenderColor(l?null:e.getLut(t.scope)).toArray01Linear().slice(0,3),c);const f=[0,0,0];return k(f,r.toPremultipliedRenderColor(n?null:e.getLut(i.scope)).toArray01Linear().slice(0,3),h*o),Tt([d[0]>0?d[0]/(d[0]+f[0]):0,d[1]>0?d[1]/(d[1]+f[1]):0,d[2]>0?d[2]/(d[2]+f[2]):0])}const jE=[];function HE(e){return jE[e]=jE[e]||new Float64Array(16)}const $E=[],ZE=new Float32Array(16);class WE{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class qE{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new WE(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,i){const n=zf.fromPoints(e.points);let r=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!n.intersectsAabb(o.aabb))continue;o.aabb.min=n.closestPoint(o.aabb.min),o.aabb.max=n.closestPoint(o.aabb.max);const a=o.aabb.getCorners();for(let e=0;e<i.length;e++){let n=!0;for(const r of a){const o=[r[0]*t,r[1]*t,r[2]];if(Y(o,o,i[e].matrix),o[0]<-1||o[0]>1||o[1]<-1||o[1]>1){n=!1;break}}if(o.lastCascade=e,r=Math.max(r,e),n)break}}return r+1}}function XE(e,t,i){const n=q([],te([],i,t),te([],e,t)),r=D(n);return 0===r?[0,0,1,0]:(k(n,n,1/r),[n[0],n[1],n[2],-W(n,t)])}function YE(e,t,i,n,r,o){const a=e.zoom,s=e.scale,l=e.worldSize,u=1/l,c=e.aspect,h=Math.sqrt(1+c*c)*Math.tan(.5*e.fovX),f=h*h,g=n-i,y=n+i;let x,v;f>g/y?(x=n,v=n*h):(x=.5*y*(1+f),v=.5*Math.sqrt(g*g+2*(n*n+i*i)*f+y*y*f*f));const b=e.projection.pixelsPerMeter(e.center.lat,l),w=[0,0,-x*u];Y(w,w,e._camera.getCameraToWorldMercator());let E=v*u;const A=function(t){return t[0]/=s,t[1]/=s,t[2]=yu(t[2],e._center.lat),t},I=e._edgeInsets;if(!(0===I.left&&0===I.top&&0===I.right&&0===I.bottom||I.left===I.right&&I.top===I.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?b:1),r=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,i,n);r[8]=2*-e.centerOffset.x/e.width,r[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);z(o,r,t);const s=new Float64Array(16);p(s,o);const u=Sf.fromInvProjectionMatrix(s,l,a,!0);for(const e of u.points){const t=A(e);E=Math.max(E,ne(L([],w,t)));}}E*=r/(r-1);const T=Math.acos(t[2]),M=Math.atan2(-t[0],-t[1]),S=new nw;S.position=w,S.setPitchBearing(T,M);const R=S.getWorldToCamera(l,b),P=E*l,D=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*P),F=S.getCameraToClipOrthographic(-P,P,-P,P,D,(P+o*b)/t[2]),O=new Float64Array(16);_(O,F,R);const B=.5*r,N=[0,0,0];Y(N,C(Math.floor(1e6*w[0])/1e6*l,Math.floor(1e6*w[1])/1e6*l,0),O),k(N,N,B);const V=[Math.floor(N[0]),Math.floor(N[1]),Math.floor(N[2])],U=[0,0,0];te(U,N,V),k(U,U,-1/B);const G=new Float64Array(16);return d(G),m(G,G,U),_(O,G,O),[O,P]}class JE extends sn{constructor(e,t,i,n){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null;}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null);}async loadGLTFFromURI(e,t){return Gg((await this.map._requestManager.transformRequest(e,ai.Model,t)).url,t)}async loadModel(e,t,i){try{const n=await this.loadGLTFFromURI(t.uri,i);if(i.aborted)return;const r=this._modelsInfo.get(e);if(!r)return;const o=Dy(n),a=r.modelSpec,s=new dy(e,a.uri,a.position,a.orientation,o);JE.applyModelSpecification(s,a),s.computeBoundsAndApplyParent(),this.models.push(s),r.model=s;}catch(n){if(i.aborted)return;this.fire(new rn(new Error(`Could not load model ${e} from ${t.uri}`,{cause:n})));}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const i in this._options.models){const n=this._options.models[i],r=this._modelsInfo.get(i);if(r&&r.model){r.modelSpec=n;const e=r.model;e.position=null!=n.position?new _u(n.position[0],n.position[1]):new _u(0,0),e.orientation=n.orientation??[0,0,0],JE.applyModelSpecification(e,n),e.computeBoundsAndApplyParent(),this.models.push(e);}else r?r.modelSpec=n:(this._modelsInfo.set(i,{modelSpec:n,model:null}),t.push(this.loadModel(i,n,e)));}0!==t.length?(await Promise.allSettled(t),e.aborted||this.fire(new nn("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new nn("data",{dataType:"source",sourceDataType:"metadata"}));}static arrayFromColorSpecification(e){const t=e;if(void 0===t)return;if(Array.isArray(t))return [t[0],t[1],t[2]];const i=pn.parse(t);return i?[i.r,i.g,i.b]:void 0}static applyModelSpecification(e,t){if(t.nodeOverrides&&JE.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&JE.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties),t.lightOverrides){const i=t.lightOverrides,n=JE.arrayFromColorSpecification(i["light-ambient-color"]),r=JE.arrayFromColorSpecification(i["light-directional-color"]);e.lightOverrides={ambientIntensity:i["light-ambient-intensity"],ambientColor:n,directionalIntensity:i["light-directional-intensity"],directionalColor:r};}else e.lightOverrides=void 0;}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const i of t)e.nodeOverrideNames.push(i);}else Object.entries(t).forEach(([t,i])=>{const n={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(i,"orientation")){const e=i.orientation;e&&(n.orientation=e);}Object.hasOwn(i,"minzoom")&&(n.minZoom=i.minzoom),Object.hasOwn(i,"maxzoom")&&(n.maxZoom=i.maxzoom),e.nodeOverrides.set(t,n);});}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const i of t)e.materialOverrideNames.push(i);}else Object.entries(t).forEach(([t,i])=>{const n=JE.arrayFromColorSpecification(i["model-color"]),r={color:void 0!==n?new pn(n[0],n[1],n[2]):new pn(1,1,1),colorMix:0,emissionStrength:0,opacity:1},o=i["model-color-mix-intensity"];void 0!==o&&(r.colorMix=o);const a=i["model-emissive-strength"];void 0!==a&&(r.emissionStrength=a);const s=i["model-opacity"];void 0!==s&&(r.opacity=s),e.materialOverrides.set(t,r);});}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){if(0===this._modelsInfo.size)return !0;for(const e of this._modelsInfo.values())if(null==e.model)return !1;return !0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return !1}reload(){this.cancelModelRequests();const e=vl(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load();}onRemove(e){this.cancelModelRequests();}setModels(e){this.models=[];const t=new Map;for(const i in e){const n=e[i],r=this._modelsInfo.get(i);r&&r.modelSpec.uri===n.uri&&t.set(i,r);}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,i]of t)i.model||t.delete(e);}this._modelsInfo=t,this._options.models=e,this.load();}}function KE(e,t,i){try{t=function(e){if(!e.variants)return e;if(!Array.isArray(e.variants))throw new Error("variants must be an array");for(const t of e.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(t.capabilities))throw new Error("capabilities must be an array");if(1===t.capabilities.length&&"meshopt"===t.capabilities[0])return Object.assign(e,t)}return e}(t);}catch(e){return new Error("Failed to process TileJSON variants",{cause:e})}const n=ot({...t,...e},["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return e.url&&t.tiles&&e.tiles&&(n.tiles=t.tiles),n.tiles=i.canonicalizeTileset(n,e.url),n}function QE(e,t,i,n,r){const o=function(i,n){if(i)return r(i);if(n){e.url&&n.tiles&&e.tiles&&delete e.tiles;const i=KE(e,n,t);if(i instanceof Error)return r(i);r(null,i);}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const o=n.every(e=>e===t),a=r.every(e=>e===i);return o&&a?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(e.data,i,n);if(a)return Vt.frame(()=>o(null,a));if(e.url){const r=new AbortController;return (async()=>{const a=await t.transformRequest(t.normalizeSourceURL(e.url,null,i,n),ai.Source,r.signal),{data:s}=await pi(a,r.signal);o(null,s);})().catch(e=>{r.signal.aborted||o(e);}),{cancel:()=>r.abort()}}return Vt.frame(()=>{const{data:t,...i}=e;o(null,i);})}function eA(e,t){const i=Math.pow(2,t.z),n=Math.floor(hr(e.getWest())*i),r=Math.floor(dr(e.getNorth())*i),o=Math.ceil(hr(e.getEast())*i),a=Math.ceil(dr(e.getSouth())*i);return t.x>=n&&t.x<o&&t.y>=r&&t.y<a}class tA{constructor(e,t,i){this.bounds=e?mu.convert(this.validateBounds(e)):null,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]}addExtraBounds(e){if(e){this.extraBounds||(this.extraBounds=[]);for(const t of e)this.extraBounds.push(mu.convert(this.validateBounds(t)));}}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom)return !1;if(this.bounds&&!eA(this.bounds,e))return !1;if(!this.extraBounds)return !0;for(const t of this.extraBounds)if(eA(t,e))return !0;return !1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;const t=new tA(e.bounds,e.minzoom,e.maxzoom);return t.addExtraBounds(e.extra_bounds),t}}const iA={loaded:!0,drawModels:function(e,t,i,n){if("opaque"===e.renderPass)return;const r=i.paint.get("model-opacity").constantOr(1),o=i.paint.get("model-elevation-reference"),a="ground"===o,s="ground"===o;if(0===r)return;const l=i.paint.get("model-cast-shadows");if("shadow"===e.renderPass){if(!l)return;if(e.terrain&&r<.65&&i._transitionablePaint._values["model-opacity"].value.expression instanceof Ga)return}const c=e.shadowRenderer,h=i.paint.get("model-receive-shadows");c&&(c.useNormalOffset=!0,h||(c.enabled=!1));const d=()=>{c&&(c.useNormalOffset=!0,h||(c.enabled=!0));},m=t.getSource();if("light-beam"===e.renderPass&&"batched-model"!==m.type)return;if("vector"===m.type||"geojson"===m.type)return function(e,t,i,n,r){const o=e.transform,a="globe"===o.projection.name,s=o.getFreeCameraOptions().position;if(!e.modelManager)return;const l=e.modelManager;i.modelManager=l;const c=e.shadowRenderer;if(!Object.hasOwn(i._unevaluatedLayout._values,"model-id"))return;const h=i._unevaluatedLayout._values["model-id"],d={...i.layout.get("model-id").parameters},f=e.style.order.indexOf(i.fqid),p=i.paint.get("model-opacity").constantOr(1);for(const _ of n){const n=t.getTile(_).getBucket(i);if(!n||n.projection.name!==o.projection.name)continue;const m=n.getModelUris();if(m&&!n.modelsRequested&&(l.addModelsFromBucket(m,r),n.modelsRequested=!0),a)d.zoom=_.overscaledZ;else {const e=Jw(_,o);d.zoom=e;}const g=h.possiblyEvaluate(d);if(Xw(e,n,_),Yw.shadowUniformsInitialized=!1,Yw.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(_.toUnwrapped()),"shadow"===e.renderPass&&c){if(1===e.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const t=o.calculatePosMatrix(_.toUnwrapped(),o.worldSize);if(Yw.tileMatrix.set(t),Yw.shadowTileMatrix.set(c.calculateShadowPassMatrixFromMatrix(t)),Yw.aabb.min=[0,0,0],Yw.aabb.max[0]=Yw.aabb.max[1]=Sr,Yw.aabb.max[2]=0,eE(n,Yw,e,i.scope))continue}const y=1<<_.canonical.z,x=[((s.x-_.wrap)*y-_.canonical.x)*Sr,(s.y*y-_.canonical.y)*Sr,s.z*y*Sr];e.conflationActive&&Object.keys(n.instancesPerModel).length>0&&e.style.isLayerClipped(i,t.getSource())&&n.updateReplacement(_,e.replacementSource,f,i.scope)&&(n.uploaded=!1,n.upload(e.context));let v=0;const E=new Array,T=new Array,M=new Array;for(let t in n.instancesPerModel){const o=n.instancesPerModel[t];o.features.length>0&&!a&&(t=g.evaluate(o.features[0].feature,{}));const c=l.getModel(t,r);if(c||l.hasURLBeenRequested(t)||n.modelUris.includes(t)||(n.modelUris.push(t),n.modelsRequested=!1),c&&c.uploaded)if(a){const t=k([],[s.x,s.y,s.z],e.transform.worldSize);$(t,t);for(let i=0;i<o.instancedDataArray.length;++i){const r=[0,0,0],a=[1,1,1],s=ue(),l=o.tileCoordinatesForInstance(i),h=o.transformForInstance(i);A(a,h),I(s,h),he(r,s);const d=o.translationForInstance(i),f=new _u(0,0);Aw(n.canonical,f,l.x,l.y);const _=u();hy(_,c,e.transform,f,r,a,d,!0,!1,!1);const m=o.colorForInstance(i),g=b([],t),y=w([],[1,1,1/wu(f.lat,e.transform.zoom)]);M.push({zScaleMatrix:y,negCameraPosMatrix:g});for(const t of c.nodes)jw(e,t,_,e.transform.expandedFarZProjMatrix,v,E,T,c.materialOverrides,p,m);++v;}}else for(const t of c.nodes)Kw(e,i,t,o,x,_,Yw);}if(a)if("shadow"===e.renderPass){for(const t of T)Hw(t.mesh,t.nodeModelMatrix,e,i);for(const t of E)Hw(t.mesh,t.nodeModelMatrix,e,i);}else qw(e,i,E,T,M);}}(e,t,i,n,Gw(e,i)),void d();if(!m.loaded())return;if("batched-model"===m.type)return function(e,t,i,n){i.resetLayerRenderingStats(e);const r=e.context,o=e.transform,a=e.style.fog,s=e.shadowRenderer;if("mercator"!==o.projection.name)return void mt(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,u=k([],[l.x,l.y,l.z],e.transform.worldSize),c=b([],$([],u)),h=wu(o.center.lat,o.zoom),d=_([],c,w([],[1,1,1/h])),m=i.paint.get("model-opacity").constantOr(1),y=new qb(r.gl.LEQUAL,qb.ReadWrite,e.depthRangeFor3D),x=new qb(r.gl.LEQUAL,qb.ReadOnly,e.depthRangeFor3D),v=new zf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),E="shadow"===e.renderPass,A="light-beam"===e.renderPass,I="none"===i.paint.get("model-color-use-theme").constantOr("default"),T=E&&s?s.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),M=i.paint.get("model-front-cutoff"),S=M[2]<1,z=vw(e,i.paint.get("model-cutoff-fade-range")),P=i.getLayerRenderingStats();((function(e,t,i,n){const r=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const a of n){const n=t.getTile(a).getBucket(i);n&&(n.setFilter(i.filter),e.conflationActive&&n.updateReplacement(a,e.replacementSource),n.evaluateTransform(e,i),e.terrain&&r>0&&n.elevationUpdate(e.terrain,r,a,i.source),n.needsReEvaluation(e,o,i)&&n.evaluate(i));}}))(e,t,i,n),function(){const l=new Map;let c,b,w;S?(c=n.length-1,b=-1,w=-1):(c=0,b=n.length,w=1);const D=R(),C=new Pe(0,0);for(let R=c;R!==b;R+=w){const c=n[R],b=t.getTile(c).getBucket(i);if(!b||!b.uploaded)continue;let w=!1;s&&(w=0===s.getMaxCascadeForTile(c.toUnwrapped()));const F=o.calculatePosMatrix(c.toUnwrapped(),o.worldSize),O=!!(4&b.modelTraits);_(zw,d,F),_(Rw,o.expandedFarZProjMatrix,F),p(Pw,zw),f(Pw,Pw);const L=!E&&s&&s.enabled?s.computeCascadeTileMatrices(F):null;!E&&S&&(p(Mw,F),Y(D,u,Mw),C.x=D[0],C.y=D[1]);const B=[];b.setFilter(i.filter);for(const t of b.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const i=t.node;let n=0;e.terrain&&i.elevation&&(n=i.elevation*e.terrain.exaggeration());const r=()=>{const e=t.aabb,i=v.min,r=v.max;return i[0]=e.min[0],i[1]=e.min[1],i[2]=e.min[2]+n,r[0]=e.max[0],r[1]=e.max[1],r[2]=e.max[2]+n,Y(i,i,F),Y(r,r,F),v},a=r(),s=t.evaluatedScale;if(s[0]<=1&&s[1]<=1&&s[2]<=1&&0===a.intersects(T))continue;if(!E){const i=a.min,n=a.max;Ow[0]=.5*(i[0]+n[0]),Ow[1]=.5*(i[1]+n[1]),Ow[2]=.5*(i[2]+n[2]);const r=G(u,Ow)*h,o=e._debugParams.lodSwitchDistance,l=o>=0;if(l&&o>=9999)t.targetLod=0;else {let a;if(l)a=o;else {const e=(n[2]-i[2])*h*s[2],t=Math.max(n[0]-i[0],n[1]-i[1])*h*Math.max(s[0],s[1]);let r;r=e>=30?1:t>=80?.5:Math.max(e,t)>=20?.25:0,a=2e3+3e3*r;}Qw(t,r,Math.min(e.frameTimeDelta,1e3/30),a,e._debugParams.lodSwitchFadeDuration);}}if(!E&&S){const e=1/6;t.cameraCollisionOpacity=u[0]>a.min[0]&&u[0]<a.max[0]&&u[1]>a.min[1]&&u[1]<a.max[1]&&u[2]*h<a.max[2]&&i.footprint&&Gp(C,i.footprint)?Math.max(t.cameraCollisionOpacity-e,0):Math.min(1,t.cameraCollisionOpacity+e);}const l=1/Au(c.canonical),d=i.anchor?i.anchor[0]:0,f=i.anchor?i.anchor[1]:0,p=[d*(s[0]-1)+t.evaluatedTranslation[0]*l,f*(s[1]-1)+t.evaluatedTranslation[1]*l,n+t.evaluatedTranslation[2]],g=Vw(new Float64Array(16),F,p,s),y=_([],g,i.globalMatrix),x=_([],o.expandedFarZProjMatrix,y),b=x[2]*d+x[6]*f+x[10]*n+x[14];i.hidden=!1;let w=m;E||(S&&(w*=t.cameraCollisionOpacity,w*=iE(g,o,t.aabb,M)),w*=tE(z,b)),0!==w?B.push({nodeInfo:t,depth:b,opacity:w,wvpForNode:x,nodeModelMatrix:y,tileModelMatrix:g,tileTranslation:p}):i.hidden=!0;}E||B.sort((e,t)=>!S||1===e.opacity&&1===t.opacity?e.depth<t.depth?-1:1:1===e.opacity?-1:1===t.opacity?1:e.depth>t.depth?-1:1);for(const t of B){const n=t.nodeInfo,u=n.node;let c=null;if(e._debugParams.show3DModelFootprints&&u.footprint){const e=u.id||u.name||"footprint";if(!l.has(e)){const i=Vw(new Float64Array(16),Rw,t.tileTranslation,t.nodeInfo.evaluatedScale);l.set(e,{node:u,mvp:i});}}const h=t.nodeInfo.evaluatedScale;Vw(Tw,zw,t.tileTranslation,h),Cw[0]=1/h[0],Cw[1]=-1/h[1],Cw[2]=1/h[2],g(Mw,Pw,Cw),_(Tw,Tw,u.globalMatrix);const d=O?0:n.evaluatedRMEA[0][2],f=n.targetLod,p=u.lodMeshes&&u.lodMeshes.length>0,m=p&&f>0&&f<1;if(E&&p&&1===Math.round(f))continue;const v=!E&&a?Nw(Sw,t.nodeModelMatrix,e.transform):null,b=E&&s?s.calculateShadowPassMatrixFromMatrix(t.nodeModelMatrix):null,T=m?2:1,M=p&&1===Math.round(f);for(let l=0;l<T;++l){const h=m?1===l:M,p=h?u.lodMeshes:u.meshes,_=m?h?-f:1-f:1;for(let l=0;l<p.length;++l){const f=p[l],g=!h&&l===u.lightMeshIndex;let T=t.wvpForNode;if(g){if(!A&&!e.terrain&&e.shadowRenderer){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);continue}T=Vw(Dw,Rw,t.tileTranslation,t.nodeInfo.evaluatedScale);}else if(A)continue;const M={defines:[]},S=[],z=!!f.normalBuffer;if(!E&&s&&(s.useNormalOffset=z),kw(M.defines,S,f,e,I?null:i.lut),O||M.defines.push("DIFFUSE_SHADED"),w&&M.defines.push("SHADOWS_SINGLE_CASCADE"),P&&(E?P.numRenderedVerticesInShadowPass+=f.vertexArray.length:P.numRenderedVerticesInTransparentPass+=f.vertexArray.length),E){Hw(f,t.nodeModelMatrix,e,i,b);continue}if(a&&"globe"!==o.projection.name){const e=f.aabb.min,t=f.aabb.max,[i,n]=a.getOpacityForBounds(v,e[0],e[1],t[0],t[1]);M.overrideFog=i>=bw||n>=bw;}const R=f.material;let D;R.occlusionTexture&&R.occlusionTexture.offsetScale&&(D=R.occlusionTexture.offsetScale,M.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),m&&M.defines.push("DITHERED_DISCARD");const C=e.getOrCreateProgram("model",M);if(!E&&s&&s.enabled)if(c!==z){for(let e=0;e<L.length;e++)Vw(Bw[e]=Bw[e]||new Float64Array(16),L[e],t.tileTranslation,t.nodeInfo.evaluatedScale);s.setupShadowsFromCascadeMatrices(Bw,C,z),c=z;}else C.setShadowUniformValues(r,s.getShadowUniformValues());e.uploadCommonUniforms(r,C,null,v);const F=R.pbrMetallicRoughness;F.metallicFactor=.9,F.roughnessFactor=.5;const B=Ub(T,Tw,Mw,u.globalMatrix,e,t.opacity,F.baseColorFactor,R.emissiveFactor,F.metallicFactor,F.roughnessFactor,R,d,i,Lw,D,void 0,void 0,_,C.fixedDefines.includes("LIGHTING_3D_MODE"));!g&&(n.hasTranslucentParts||t.opacity<1)&&C.draw(e,r.gl.TRIANGLES,y,Hb.disabled,Wb.disabled,Jb.backCCW,B,i.id,f.vertexBuffer,f.indexBuffer,f.segments,i.paint,e.transform.zoom,void 0,S),C.draw(e,r.gl.TRIANGLES,g?x:y,Hb.disabled,g||t.opacity<1||n.hasTranslucentParts?Wb.alphaBlended:Wb.unblended,Jb.backCCW,B,i.id,f.vertexBuffer,f.indexBuffer,f.segments,i.paint,e.transform.zoom,void 0,S);}}}}if(e._debugParams.show3DModelFootprints&&l.size>0){const t=Array.from(l.keys()).sort();for(const i of t){const{node:t,mvp:n}=l.get(i);$w(e,0,t,n);}}}();}(e,t,i,n),void d();if("model"!==m.type)return;const y=m.getModels(),x=[],v=e.transform.getFreeCameraOptions().position,E=k([],[v.x,v.y,v.z],e.transform.worldSize);$(E,E);const T=[],M=[];let S=0;for(const n of y){const r=t.getFeatureState("",n.id),o={type:"Unknown",id:n.id,properties:n.featureProperties},l=i.paint.get("model-rotation").evaluate(o,r),u=i.paint.get("model-scale").evaluate(o,r),c=i.paint.get("model-translation").evaluate(o,r),h=i.paint.get("model-opacity").evaluate(o,r);Zw(i,n.id,r,n.featureProperties,n.nodeOverrideNames,n.nodeOverrides),Ww(i,n.id,r,n.featureProperties,n.materialOverrideNames,n.materialOverrides),n.nodeOverrides.size>0&&n.computeBoundsAndApplyParent(),n.computeModelMatrix(e,l,u,c,s,a,!1);const d=b([],E),f=w([],[1,1,1/wu(n.position.lat,e.transform.zoom)]);x.push({zScaleMatrix:f,negCameraPosMatrix:d});for(const t of n.nodes)jw(e,t,n.matrix,e.transform.expandedFarZProjMatrix,S,T,M,n.materialOverrides,h,void 0,n.lightOverrides);S++;}if(T.sort((e,t)=>t.depth-e.depth),"shadow"!==e.renderPass){if(e._debugParams.show3DModelFootprints){const t=e.transform.projMatrix,i=new Map,n=(e,n)=>{if(e.footprint){const r=e.id||e.name||"footprint";if(!i.has(r)){const o=_([],t,n);i.set(r,{node:e,mvp:o});}}};for(const e of M)n(e.node,e.modelMatrix);for(const e of T)n(e.node,e.modelMatrix);const r=Array.from(i.keys()).sort();for(const t of r){const{node:n,mvp:r}=i.get(t);$w(e,0,n,r);}}qw(e,i,T,M,x),d();}else {for(const t of M)Hw(t.mesh,t.nodeModelMatrix,e,i);for(const t of T)Hw(t.mesh,t.nodeModelMatrix,e,i);d();}},prepare:function(e,t,i){const n=t.getSource();if(!n.loaded())return;if("vector"===n.type||"geojson"===n.type)return void(i.modelManager&&i.modelManager.upload(i,Gw(i,e)));if("batched-model"===n.type)return;if("model"!==n.type)return;const r=n.getModels();for(const e of r)e.upload(i.context);},shaders:PE,programUniforms:kE,ShadowRenderer:class{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new qE,this._depthMode=new qb(e.context.gl.LEQUAL,qb.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(e,t){const i=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!t||!t.properties)return;const n=t.properties.get("shadow-intensity"),r=t.properties.get("shadow-draw-before-layer");if(!t.shadowsEnabled()||n<=0)return;let o=-1,a=0;for(const t of i.style.order){const n=i.style._mergedLayers[t];n.hasShadowPass()&&!n.isHidden(e.zoom)&&(o=a),!r||r!==t&&r!==n.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1;}if(this._enabled=o>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=o);const s=i.context,l=this._shadowParameters.shadowMapResolution,u=this._shadowParameters.shadowMapResolution;if(0===this._cascades.length||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let e=0;e<this._shadowParameters.cascadeCount;++e){const e=s.gl,t=s.createFramebuffer(l,u,0,"texture"),i=new p_(s,{width:l,height:u,data:null},e.DEPTH_COMPONENT16);t.depthAttachment.set(i.texture),this._cascades.push({framebuffer:t,texture:i,matrix:[],far:0,boundingSphereRadius:0,frustum:new Sf,scale:0});}}this.shadowDirection=UE(t);let c=0;if(e.elevation){const t=e.elevation,i=[1e4,-1e4];t.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);}),1e4!==i[0]&&(c=(i[1]-i[0])*t.exaggeration());}const h=1.5*e.cameraToCenterDistance,d=3*h,f=new Float64Array(16);for(let t=0;t<this._cascades.length;++t){const i=this._cascades[t];let n=e.height/50,r=1;1===this._shadowParameters.cascadeCount?r=d:0===t?r=h:(n=h,r=d);const[o,a]=YE(e,this.shadowDirection,n,r,this._shadowParameters.shadowMapResolution,c);i.scale=e.scale,i.matrix=o,i.boundingSphereRadius=a,p(f,i.matrix),i.frustum=Sf.fromInvProjectionMatrix(f,1,0,!0),i.far=r;}const _=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[_].far,this._cascades[_].far],this._uniformValues.u_shadow_intensity=n,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=Nb.ShadowMap0,this._uniformValues.u_shadowmap_1=Nb.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const m=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(m){const i=m.getMinMaxForTile(e);i&&(t=i);}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max);}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e;}drawShadowPass(e,t){if(!this.enabled)return;const i=this.painter,n=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),n.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let r=0;r<this._numCascadesToRender;++r){i.currentShadowCascade=r,n.bindFramebuffer.set(this._cascades[r].framebuffer.framebuffer),n.clear({color:pn.white,depth:1});for(const n of e.order){const r=e._mergedLayers[n];if(!r.hasShadowPass()||r.isHidden(i.transform.zoom))continue;const o=e.getLayerSourceCache(r),a=o?t[o.id]:void 0;("model"===r.type||a&&a.length)&&i.renderLayer(i,o,r,a);}}i.currentShadowCascade=0;}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,n=i.gl,r=t.directionalLight,o=t.ambientLight;if(!r||!o)return;const a=[],s=vw(e,e.longestCutoffRange);s.shouldRenderCutoff&&a.push("RENDER_CUTOFF"),a.push("RENDER_SHADOWS"),this.useNormalOffset&&a.push("NORMAL_OFFSET");const l=GE(t,r,o),u=new qb(n.LEQUAL,qb.ReadOnly,e.depthRangeFor3D),c=new Hb({func:n.EQUAL,mask:255},0,255,n.KEEP,n.KEEP,n.KEEP);for(const t of this._groundShadowTiles){const r=t.toUnwrapped(),o=e.isTileAffectedByFog(t),h=e.getOrCreateProgram("groundShadow",{defines:a,overrideFog:o});this.setupShadows(r,h),e.uploadCommonUniforms(i,h,r,null,s);const d=DE(e.transform.calculateProjMatrix(r),l);h.draw(e,n.TRIANGLES,u,c,Wb.multiply,Jb.disabled,d,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,null,e.transform.zoom,null,null);}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(e){const t=this.painter.transform,i=t.calculatePosMatrix(e,t.worldSize);return _(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}calculateShadowPassMatrixFromMatrix(e){return _(ZE,this._cascades[this.painter.currentShadowCascade].matrix,e)}setupShadows(e,t,i){if(!this.enabled)return;const n=this.painter.transform,r=this.painter.context,o=r.gl,a=this._uniformValues,s=n.calculatePosMatrix(e,n.worldSize);for(let e=0;e<this._cascades.length;e++){const t=HE(e);_(t,this._cascades[e].matrix,s),a[0===e?"u_light_matrix_0":"u_light_matrix_1"]=t,r.activeTexture.set(o.TEXTURE0+Nb.ShadowMap0+e),this._cascades[e].texture.bindExtraParam(o.LINEAR,o.LINEAR,o.CLAMP_TO_EDGE,o.CLAMP_TO_EDGE,o.GREATER);}if(this.useNormalOffset=!!i,this.useNormalOffset){const t=Au(e.canonical),r=2/n.tileSize*Sr/this._shadowParameters.shadowMapResolution,o=r*this._cascades[0].boundingSphereRadius,s=r*this._cascades.at(-1).boundingSphereRadius,l=("vector-tile"===i?1:3)*function(e){const t=tt((e-22)/-22,0,1);return .125*(1-t)+4*t}(n.zoom);a.u_shadow_normal_offset=[t,o*l,s*l],a.u_shadow_bias=[1e-4,.0012,.012];}else a.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(r,a);}computeCascadeTileMatrices(e){const t=this._shadowParameters.cascadeCount;for(let i=0;i<t;i++)_($E[i]=$E[i]||new Float64Array(16),this._cascades[i].matrix,e);return $E.length=t,$E}setupShadowsFromMatrix(e,t,i=!1){if(!this.enabled)return;const n=this._shadowParameters.cascadeCount;for(let t=0;t<n;t++)_(HE(t),this._cascades[t].matrix,e);jE.length=n,this.setupShadowsFromCascadeMatrices(jE,t,i);}setupShadowsFromCascadeMatrices(e,t,i=!1){if(!this.enabled)return;const n=this.painter.context,r=n.gl,o=this._uniformValues;for(let t=0;t<this._shadowParameters.cascadeCount;t++)o[0===t?"u_light_matrix_0":"u_light_matrix_1"]=e[t],n.activeTexture.set(r.TEXTURE0+Nb.ShadowMap0+t),this._cascades[t].texture.bindExtraParam(r.LINEAR,r.LINEAR,r.CLAMP_TO_EDGE,r.CLAMP_TO_EDGE,r.GREATER);if(this.useNormalOffset=i,i){const e=this._shadowParameters.normalOffset;o.u_shadow_normal_offset=[1,e,e],o.u_shadow_bias=[6e-5,.0012,.012];}else o.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(n,o);}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(e,t,i,n){if(n[2]>=0)return {};const r=function(e,t,i){const n=i/(1<<e.canonical.z);return new zf([e.canonical.x*n+e.wrap*i,e.canonical.y*n+e.wrap*i,0],[(e.canonical.x+1)*n+e.wrap*i,(e.canonical.y+1)*n+e.wrap*i,t])}(e,t,i).getCorners(),o=t/-n[2];n[0]<0?(O(r[0],r[0],[n[0]*o,0,0]),O(r[3],r[3],[n[0]*o,0,0])):n[0]>0&&(O(r[1],r[1],[n[0]*o,0,0]),O(r[2],r[2],[n[0]*o,0,0])),n[1]<0?(O(r[0],r[0],[0,n[1]*o,0]),O(r[1],r[1],[0,n[1]*o,0])):n[1]>0&&(O(r[2],r[2],[0,n[1]*o,0]),O(r[3],r[3],[0,n[1]*o,0]));const a={};return a.vertices=r,a.planes=[XE(r[1],r[0],r[4]),XE(r[2],r[1],r[5]),XE(r[3],r[2],r[6]),XE(r[0],r[3],r[7])],a}addShadowReceiver(e,t,i){this._receivers.add(e,zf.fromTileIdAndHeight(e,t,i));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}},drawGroundEffect:VE,queryModelLayerRendered:function(e,t,i,n){const r=i.getSource();if(!r||"model"!==r.type)return {};const o=r,a={};a[e.id]=[];const s=a[e.id];let l=0;for(const r of o.models){const o=i.getFeatureState(e.sourceLayer,r.id),a={type:"Unknown",id:r.id,properties:r.featureProperties},u=e.paint.get("model-rotation").evaluate(a,o),c=e.paint.get("model-scale").evaluate(a,o),h=e.paint.get("model-translation").evaluate(a,o),d=e.paint.get("model-elevation-reference");let f=[];hy(f,r,n,r.position,u,c,h,"ground"===d,"ground"===d,!1),"globe"===n.projection.name&&(f=sy(f,n));const p=_([],n.projMatrix,f),m=ly(t.isPointQuery()?t.screenBounds:t.screenGeometry,n,p,r.aabb);if(null!=m){const t=new Bb(void 0,0,0,0,r.id);t.layer=e.layer,t.properties=structuredClone(r.featureProperties),t.properties.layer=e.id,t.properties.uri=r.uri,t.properties.orientation=r.orientation,t.sourceLayer=e.sourceLayer,t.geometry={type:"Point",coordinates:[r.position.lng,r.position.lat]},t.state=o,t.source=e.source,s.push({featureIndex:l,feature:t,intersectionZ:m});}++l;}return a},queryModelLayerIntersectsFeature:function(e,t,i,n,r,o){if(!e.modelManager)return !1;const a=e.modelManager,s=t.tile.getBucket(e);if(!(s&&s instanceof xb))return !1;for(const n in s.instancesPerModel){const l=s.instancesPerModel[n],u=void 0!==i.id?i.id:i.properties&&Object.hasOwn(i.properties,"id")?i.properties.id:void 0;if(Object.hasOwn(l.idToFeaturesIndex,u)){const i=l.features[l.idToFeaturesIndex[u]],c=a.getModel(n,o||e.scope);if(!c)return !1;let h=[];const d=new _u(0,0),f=s.canonical;let p=Number.MAX_VALUE;for(let e=0;e<i.instancedDataCount;++e){const n=16*(i.instancedDataOffset+e),o=l.instancedDataArray.float32,a=[o[n+4],o[n+5],o[n+6]];Aw(f,d,Math.floor(o[n]),Math.floor(o[n+1])),hy(h,c,r,d,i.rotation,i.scale,a,!1,!1,!1),"globe"===r.projection.name&&(h=sy(h,r));const s=_([],r.projMatrix,h),u=t.queryGeometry,m=ly(u.isPointQuery()?u.screenBounds:u.screenGeometry,r,s,c.aabb);null!=m&&(p=Math.min(m,p));}return p!==Number.MAX_VALUE&&p}}return !1},loadMatchingModelFeature:function(e,t,i,n){const r=e.getNodesInfo()[t];if(!r||r.hiddenByReplacement||!r.node.meshes)return;let o=Number.MAX_VALUE;const a=r.node,s=i.tile,l=n.calculatePosMatrix(s.tileID.toUnwrapped(),n.worldSize),u=r.evaluatedScale;let c=0;n.elevation&&a.elevation&&(c=a.elevation*n.elevation.exaggeration()),m(l,l,[(a.anchor?a.anchor[0]:0)*(u[0]-1),(a.anchor?a.anchor[1]:0)*(u[1]-1),c]),g(l,l,u);const h=i.queryGeometry,d=h.isPointQuery()?h.screenBounds:h.screenGeometry,f=function(e){const t=_([],l,e.globalMatrix);_(t,n.expandedFarZProjMatrix,t);for(let i=0;i<e.meshes.length;++i){const r=e.meshes[i];if(i===e.lightMeshIndex)continue;const a=ly(d,n,t,r.aabb);null!=a&&(o=Math.min(a,o));}if(e.children)for(const t of e.children)f(t);};if(f(a),o===Number.MAX_VALUE)return;const p=new _u(0,0);return Aw(s.tileID.canonical,p,r.node.anchor[0],r.node.anchor[1]),{intersectionZ:o,position:p,feature:r.feature}},ModelSource:JE,Tiled3dModelSource:class extends sn{constructor(e,t,i,n){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(n);}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const e=vl(this.id,this.scope);this.load(()=>this.map.style.clearSource(e));}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}load(e){this._loaded=!1,this.fire(new nn("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map.getWorldview();this._tileJSONRequest=QE(this._options,this.map._requestManager,t,i,(n,r)=>{this._tileJSONRequest=null,this._loaded=!0,n?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new rn(n))):r&&(Object.assign(this,r),r.bounds&&(this.tileBounds=new tA(r.bounds,this.minzoom,this.maxzoom)),Ui(r.tiles,this.map._requestManager._customAccessToken),this.fire(new nn("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new nn("data",{dataType:"source",sourceDataType:"content"}))),e&&e(n);});}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}async loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),n=!e.actor||"expired"===e.state;if(n)e.actor=this.dispatcher.getActor();else {if("loading"===e.state)return void(e.reloadCallback=t);if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}}const r=n?"loadTile":"reloadTile",o=new AbortController;e.request=o;const a=(i,n)=>(delete e.request,e.aborted?t(null):i&&!li(i)?t(i):(this.map._refreshExpiredTiles&&n&&e.setExpiryData(wt(n.headers)),e.loadModelData(n,this.map.painter),e.state="loaded",t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null))));try{const n=await this.map._requestManager.transformRequest(i,ai.Tile,o.signal);if(o.signal.aborted)return t(null);const s={request:n,data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:e.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:Vt.devicePixelRatio,promoteId:this.promoteId};e.request=e.actor.sendCancelable(r,s,{},a);}catch(e){if(o.signal.aborted)return t(null);t(e);}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}serialize(){return {...this._options}}},loadModel:async function(e,t,i){const n=await Gg(e),r=new dy(t,i,void 0,void 0,Dy(n));return r.computeBoundsAndApplyParent(),r}};class nA{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Za(Sr,Sr,512),this.featureIndexArray=new Cc,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map;}insert(e,t,i,n,r,o=0,a=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let e=0;e<t.length;e++){const i=t[e],n=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];n[0]=Math.min(n[0],t.x),n[1]=Math.min(n[1],t.y),n[2]=Math.max(n[2],t.x),n[3]=Math.max(n[3],t.y);}0!==a&&(n[0]-=a,n[1]-=a,n[2]+=a,n[3]+=a),n[0]<Sr&&n[1]<Sr&&n[2]>=0&&n[3]>=0&&l.insert(s,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Oh(new Zp(this.rawTileData)).layers,this.sourceLayerCoder=new Ob(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t){const{tilespaceGeometry:i,transform:n,tileTransform:r,pixelPosMatrix:o,availableImages:a,worldview:s}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,u=i.bufferedTilespaceBounds,c=this.grid.queryKeys(u.min.x,u.min.y,u.max.x,u.max.y,(e,t,n,r)=>qh(i.bufferedTilespaceGeometry,e-l,t-l,n+l,r+l));c.sort(oA);let h=null;n.elevation&&c.length>0&&(h=vb.create(n.elevation,this.tileID));const d={};let f;for(let l=0;l<c.length;l++){const u=c[l];if(u===f)continue;f=u;const p=this.featureIndexArray.get(u);let _=null;this.is3DTile?this.loadMatchingModelFeature(d,p,e,i,n,s):this.loadMatchingFeature(d,p,e,a,s,(e,a,s,l=0)=>(_||(_=Cu(e,this.tileID.canonical,r)),a.queryIntersectsFeature(i,e,s,_,this.z,n,o,h,l,t.scope)));}return d}loadMatchingFeature(e,t,i,n,r,o){const{featureIndex:a,bucketIndex:s,sourceLayerIndex:l,layoutVertexArrayOffset:u}=t,c=this.bucketLayerIDs[s],h=i.layers,d=Object.keys(h);if(d.length&&!pt(d,c))return;const f=i.sourceCache,p=this.sourceLayerCoder.decode(l),_=this.vtLayers[p].feature(a),m=this.getId(_,p);for(let t=0;t<c.length;t++){const i=c[t];if(!h[i])continue;const{styleLayer:s,targets:l}=h[i];let d={};void 0!==m&&(d=f.getFeatureState(s.sourceLayer,m));const p=!o||o(_,s,d,u);if(!p)continue;const g=new Bb(_,this.z,this.x,this.y,m);g.tile=this.tileID.canonical,g.state=d;let y=this.serializedLayersCache.get(i);y||(y=s.serialize(),y.id=i,this.serializedLayersCache.set(i,y)),g.source=y.source,g.sourceLayer=y["source-layer"],g.layer={...y},g.layer.paint=rA(y.paint,s.paint,_,d,n),g.layer.layout=rA(y.layout,s.layout,_,d,n);const x=new Hs(this.tileID.overscaledZ,{worldview:r});let v=!1;for(const e of l){this.updateFeatureProperties(g,e);const{filter:t}=e;if(t)if(_.properties=g.properties,t.needGeometry){const e=Fu(_,!0);if(!t.filter(x,e,this.tileID.canonical))continue}else if(!t.filter(x,_))continue;v=!0,e.targetId&&this.addFeatureVariant(g,e);}v&&this.appendToResult(e,i,a,g,p);}}loadMatchingModelFeature(e,t,i,n,r,o){const{featureIndex:a,bucketIndex:s}=t,l=this.bucketLayerIDs[s],u=i.layers,c=Object.keys(u);if(!c.length||pt(c,l))for(let t=0;t<l.length;t++){const s=l[t],{styleLayer:c,targets:h}=u[s];if("model"!==c.type)continue;const d=n.tile,f=d.getBucket(c);if(!f||!f.isTiled3dModelBucket)continue;if(!iA.loadMatchingModelFeature)continue;const p=iA.loadMatchingModelFeature(f,a,n,r);if(!p)continue;const{z:_,x:m,y:g}=d.tileID.canonical,{feature:y,intersectionZ:x,position:v}=p;let b={};void 0!==y.id&&(b=i.sourceCache.getFeatureState(c.sourceLayer,y.id));const w=new Bb({},_,m,g,y.id);w.tile=this.tileID.canonical,w.state=b,w.properties=y.properties,w.geometry={type:"Point",coordinates:[v.lng,v.lat]};let E=this.serializedLayersCache.get(s);E||(E=c.serialize(),E.id=s,this.serializedLayersCache.set(s,E)),w.source=E.source,w.sourceLayer=E["source-layer"],w.layer={...E};const A=new Hs(this.tileID.overscaledZ,{worldview:o});let I=!1;for(const e of h){this.updateFeatureProperties(w,e);const{filter:t}=e;if(t)if(y.properties=w.properties,t.needGeometry){if(!t.filter(A,y,this.tileID.canonical))continue}else if(!t.filter(A,y))continue;I=!0,e.targetId&&this.addFeatureVariant(w,e);}I&&this.appendToResult(e,s,a,w,x);}}updateFeatureProperties(e,t,i){if(t.properties){const n={};for(const r in t.properties){const o=t.properties[r].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,i);null!=o&&(n[r]=o);}e.properties=n;}}addFeatureVariant(e,t,i){const n={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(n.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(n);}appendToResult(e,t,i,n,r){let o=e[t];void 0===o&&(o=e[t]=[]),o.push({featureIndex:i,feature:n,intersectionZ:r});}lookupSymbolFeatures(e,t,i,n,r,o){const a={};this.loadVTLayers();for(const s of e)this.loadMatchingFeature(a,{bucketIndex:t,sourceLayerIndex:i,featureIndex:s,layoutVertexArrayOffset:0},n,r,o);return a}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const n=this.sourceLayerCoder.decode(i),r=this.vtFeatures[n];if(r[t])return r[t];const o=this.vtLayers[n].feature(t);return r[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return !0;return !1}getId(e,t){let i=e.id;if(this.promoteId){const n=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[t];if(null!=n)if(Array.isArray(n)){if(!this.promoteIdExpression){const e=ka(n);if("success"!==e.result){const t=e.value.map(e=>`${e.key}: ${e.message}`).join(", ");return void mt(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value;}i=this.promoteIdExpression.evaluate({zoom:0},e);}else i=e.properties[n];"boolean"==typeof i&&(i=Number(i));}return i}}function rA(e,t,i,n,r){return ht(e,(e,o)=>{const a=t instanceof Ks?t.get(o):null;return a&&a.evaluate?a.evaluate(i,n,void 0,r):a})}function oA(e,t){return t-e}async function aA(){return Promise.resolve()}qa(nA,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const sA={circle:class extends zl{constructor(e,t,i,n){super(e,{layout:$x||($x=new il({"circle-sort-key":new el(nl.layout_circle["circle-sort-key"]),"circle-elevation-reference":new Qs(nl.layout_circle["circle-elevation-reference"]),visibility:new Qs(nl.layout_circle.visibility)})),paint:Zx||(Zx=new il({"circle-radius":new el(nl.paint_circle["circle-radius"]),"circle-color":new el(nl.paint_circle["circle-color"]),"circle-blur":new el(nl.paint_circle["circle-blur"]),"circle-opacity":new el(nl.paint_circle["circle-opacity"]),"circle-translate":new Qs(nl.paint_circle["circle-translate"]),"circle-translate-anchor":new Qs(nl.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Qs(nl.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Qs(nl.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new el(nl.paint_circle["circle-stroke-width"]),"circle-stroke-color":new el(nl.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new el(nl.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new Qs(nl.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n);}createBucket(e){return new wd(e)}queryRadius(e){const t=e;return nv("circle-radius",this,t)+nv("circle-stroke-width",this,t)+rv(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,n,r,o,a,s){const l=av(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return uv(e,n,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return ["circle"]}getDefaultProgramParams(e,t,i){const n=lv(this);return {config:new fh(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}is3D(e){return !e&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}mayUse(e){return "HD"===e&&Rl(this,"circle-elevation-reference",e=>"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?iv():Promise.resolve()}},heatmap:class extends zl{createBucket(e){return new pv(e)}constructor(e,t,i,n){super(e,{layout:_v||(_v=new il({visibility:new Qs(nl.layout_heatmap.visibility)})),paint:mv||(mv=new il({"heatmap-radius":new el(nl.paint_heatmap["heatmap-radius"]),"heatmap-weight":new el(nl.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Qs(nl.paint_heatmap["heatmap-intensity"]),"heatmap-color":new tl(nl.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Qs(nl.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=yv({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null);}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}queryRadius(e){return nv("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,n,r,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,i);return uv(e,n,o,a,s,!0,!0,new Pe(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,i){return "heatmap"===e?{config:new fh(this,{zoom:t,lut:i}),overrideFog:!1}:{}}},hillshade:class extends zl{constructor(e,t,i,n){super(e,{layout:xv||(xv=new il({visibility:new Qs(nl.layout_hillshade.visibility)})),paint:vv||(vv=new il({"hillshade-illumination-direction":new Qs(nl.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Qs(nl.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Qs(nl.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Qs(nl.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Qs(nl.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Qs(nl.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new Qs(nl.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n);}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,i){return {overrideFog:!1}}},fill:class extends zl{constructor(e,t,i,n){super(e,{layout:bv||(bv=new il({"fill-sort-key":new el(nl.layout_fill["fill-sort-key"]),visibility:new Qs(nl.layout_fill.visibility),"fill-elevation-reference":new Qs(nl.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new el(nl.layout_fill["fill-construct-bridge-guard-rail"])})),paint:wv||(wv=new il({"fill-antialias":new Qs(nl.paint_fill["fill-antialias"]),"fill-opacity":new el(nl.paint_fill["fill-opacity"]),"fill-color":new el(nl.paint_fill["fill-color"]),"fill-outline-color":new el(nl.paint_fill["fill-outline-color"]),"fill-translate":new Qs(nl.paint_fill["fill-translate"]),"fill-translate-anchor":new Qs(nl.paint_fill["fill-translate-anchor"]),"fill-pattern":new el(nl.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new Qs(nl.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new Qs(nl.paint_fill["fill-emissive-strength"]),"fill-z-offset":new el(nl.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new el(nl.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new el(nl.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t,i){return {config:new fh(this,{zoom:t,lut:i}),overrideFog:!1}}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 bh(e)}queryRadius(){return rv(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,n,r,o){return !e.queryGeometry.isAboveHorizon&&Nh(ov(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(e){if(0!==this.paint.get("fill-z-offset").constantOr(1))return !0;const t=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?t&&!e:t}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}mayUse(e){return "HD"===e&&Rl(this,"fill-elevation-reference",e=>"none"!==e)}prepare(){return this.mayUse("HD")?iv():Promise.resolve()}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends zl{constructor(e,t,i,n){super(e,{layout:Iv||(Iv=new il({visibility:new Qs(nl["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new Qs(nl["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new Qs(nl["layout_fill-extrusion"]["source-max-zoom"])})),paint:Tv||(Tv=new il({"fill-extrusion-opacity":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new el(nl["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new el(nl["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new el(nl["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new el(nl["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new el(nl["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new el(nl["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new el(nl["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new el(nl["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new Qs(nl["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new Ax(e)}queryRadius(){return rv(this.paint.get("fill-extrusion-translate"))}is3D(e){return !0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,i,n,r,o,a,s,l){const u=av(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,i),h=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],f=s&&o.elevation,p=o.elevation?o.elevation.exaggeration():1,_=e.tile.getBucket(this);if(_ instanceof Ax){const e=_.centroidData.find(e=>l>=e.vertexArrayOffset&&l<e.vertexArrayOffset+e.vertexCount);if(e&&e.flags&cx)return !1;if(f){const e=_.centroidVertexArray,t=l+1;t<e.length&&(d[0]=e.geta_centroid_pos0(t),d[1]=e.geta_centroid_pos1(t));}}if(0===d[0]&&1===d[1])return !1;"globe"===o.projection.name&&(n=Bx([n],[new Pe(0,0),new Pe(Sr,Sr)],e.tileID.canonical).map(e=>e.polygon).flat());const m=f?s:null,[g,y]=Ov(o,n,h,c,u,a,m,d,p,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return Fv(g,y,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},building:class extends zl{constructor(e,t,i,n){super(e,{layout:Mv||(Mv=new il({visibility:new Qs(nl.layout_building.visibility),"building-facade":new el(nl.layout_building["building-facade"]),"building-facade-floors":new el(nl.layout_building["building-facade-floors"]),"building-facade-unit-width":new el(nl.layout_building["building-facade-unit-width"]),"building-facade-window":new el(nl.layout_building["building-facade-window"]),"building-roof-shape":new el(nl.layout_building["building-roof-shape"]),"building-height":new el(nl.layout_building["building-height"]),"building-base":new el(nl.layout_building["building-base"]),"building-flood-light-wall-radius":new el(nl.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new el(nl.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new el(nl.layout_building["building-flip-roof-orientation"])})),paint:Sv||(Sv=new il({"building-opacity":new Qs(nl.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Qs(nl.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Qs(nl.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Qs(nl.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Qs(nl.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Qs(nl.paint_building["building-vertical-scale"]),"building-cast-shadows":new Qs(nl.paint_building["building-cast-shadows"]),"building-color":new el(nl.paint_building["building-color"]),"building-emissive-strength":new el(nl.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Qs(nl.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Qs(nl.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Qs(nl.paint_building["building-front-cutoff"]),"building-flood-light-color":new Qs(nl.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Qs(nl.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Qs(nl.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "HD"===e}prepare(){return async function(){return function(){if(!vt(self))return null;if(null!=Xx||null!=qx)return null;if(null!=Wx)return Wx;const e=fetch(Ht());return Wx=function(e){let t,i,n,r,o;function a(){t=new Uint8Array(o.buffer),i=new Int16Array(o.buffer),n=new Int32Array(o.buffer),r=new Float32Array(o.buffer);}function s(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:s,f:function(e){const i=t.length,n=Math.max(e>>>0,Math.ceil(1.2*i)),r=Math.ceil((n-i)/65536);try{return o.grow(r),a(),!0}catch(e){return !1}},g:s,b:l,c:l,d:l,e:l}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,u):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,u))).then(e=>{const s=e.instance.exports;return (0,s.g)(),o=s.f,a(),new kx({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getAOPtr:s.y,getAOLength:s.z,getUVPtr:s.A,getUVLength:s.B,getFauxFacadePtr:s.C,getFauxFacadeLength:s.D,getIndicesPtr:s.E,getIndicesLength:s.F,getBuildingPart:s.G,getRingCount:s.H,getRingPtr:s.I,getRingLength:s.J,malloc:s.K,free:s.L,heapU8:t,heap16:i,heap32:n,heapF32:r})})}(e).then(e=>{Wx=null,Xx=e;}).catch(e=>{mt("Could not load building-gen"),Wx=null,qx=e;}),Wx}()}()}createBucket(e){return new Kx(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return !0}canCastShadows(){return !0}is3D(e){return !0}queryRadius(e){return 0}queryIntersectsFeature(e,t,i,n,r,o,a,s,l,u){let c=this.layout.get("building-height").evaluate(t,i);const h=this.layout.get("building-base").evaluate(t,i),d=e.tile.getBucket(this).getFootprint(t);if(d){if(0!==d.hiddenFlags)return !1;c=d.height;}const[f,p]=Ov(o,n,h,c,new Pe(0,0),a,null,[0,0],1,o.center.lat,e.tileID.canonical),_=e.queryGeometry;return Fv(f,p,_.isPointQuery()?_.screenBounds:_.screenGeometry)}},line:class extends zl{constructor(e,t,i,n){const r=jv();super(e,r,t,i,n),r.layout&&(this.layout=new Ks(r.layout)),this.gradientVersion=0,this.borderGradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Mo,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}else if("line-gradient-use-theme"===e)this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;else if("line-border-gradient"===e){const e=this._transitionablePaint._values["line-border-gradient"].value.expression;this.borderStepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Mo,this.borderGradientVersion=(this.borderGradientVersion+1)%Number.MAX_SAFE_INTEGER;}else "line-border-gradient-use-theme"===e&&(this.borderGradientVersion=(this.borderGradientVersion+1)%Number.MAX_SAFE_INTEGER);}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}borderGradientExpression(){return this._transitionablePaint._values["line-border-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if($v)return $v;const e=jv();return $v=new Hv(e.paint.properties["line-width"].specification),$v.useIntegerZoom=!0,$v})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new gd(e)}getProgramIds(){const e=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return "default"!==this.paint.get("line-blend-mode")&&e.push("lineBlendComposite"),e}getDefaultProgramParams(e,t,i){if("lineBlendComposite"===e)return {};const n=kv(this);return {config:new fh(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,i=Xv(nv("line-width",this,t),nv("line-gap-width",this,t)),n=nv("line-offset",this,t);return i/2+Math.abs(n)+rv(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,r,o){if(e.queryGeometry.isAboveHorizon)return !1;const a=ov(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),s=e.pixelToTileUnitsFactor/2*Xv(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(n=function(e,t){const i=[],n=new Pe(0,0);for(let r=0;r<e.length;r++){const o=e[r],a=[];for(let e=0;e<o.length;e++){const i=o[e],r=o[e+1],s=0===e?n:i.sub(o[e-1])._unit()._perp(),l=e===o.length-1?n:r.sub(i)._unit()._perp(),u=s._add(l)._unit();u._mult(1/(u.x*l.x+u.y*l.y)),a.push(u._mult(t)._add(i));}i.push(a);}return i}(n,l*e.pixelToTileUnitsFactor)),function(e,t,i){for(let n=0;n<t.length;n++){const r=t[n];if(e.length>=3)for(let t=0;t<r.length;t++)if(Wh(e,r[t]))return !0;if(Vh(e,r,i))return !0}return !1}(a,n,s)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(e){return !this.hasElevatedBuckets||this.layout&&"hd-road-markup"===this.layout.get("line-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("line-elevation-reference")}mayUse(e){return "HD"===e&&Rl(this,"line-elevation-reference",e=>"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?iv():Promise.resolve()}hasOffscreenPass(){return "default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo();}onRemove(e){this._destroyLineBlendFbo(e.painter&&e.painter.context&&e.painter.context.gl||void 0);}_clear(){this._destroyLineBlendFbo();}_destroyLineBlendFbo(e){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),e&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(e),this.lineBlendDensityReadback=null;}},symbol:Qv,background:class extends zl{constructor(e,t,i,n){super(e,{layout:eb||(eb=new il({visibility:new Qs(nl.layout_background.visibility)})),paint:tb||(tb=new il({"background-pitch-alignment":new Qs(nl.paint_background["background-pitch-alignment"]),"background-color":new Qs(nl.paint_background["background-color"]),"background-pattern":new Qs(nl.paint_background["background-pattern"]),"background-opacity":new Qs(nl.paint_background["background-opacity"]),"background-emissive-strength":new Qs(nl.paint_background["background-emissive-strength"]),"background-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,i){return {overrideFog:!1}}is3D(e){return "viewport"===this.paint.get("background-pitch-alignment")}},raster:ab,"raster-particle":pb,sky:class extends zl{constructor(e,t,i,n){super(e,{layout:ub||(ub=new il({visibility:new Qs(nl.layout_sky.visibility)})),paint:cb||(cb=new il({"sky-type":new Qs(nl.paint_sky["sky-type"]),"sky-atmosphere-sun":new Qs(nl.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Qs(nl.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Qs(nl.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Qs(nl.paint_sky["sky-gradient-radius"]),"sky-gradient":new tl(nl.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Qs(nl.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Qs(nl.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Qs(nl.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp();}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0;}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=yv({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return !1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),n=!i,r=e.style.light,o=r.properties.get("position");return n&&"viewport"===r.properties.get("anchor")&&mt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?mb(o.azimuthal,90-o.polar,t):mb(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return mb(i[0],90-i[1],t)}isSky(){return !0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const e=this.paint.get("sky-type");return "atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends zl{constructor(e,t,i,n){super(e,{paint:hb||(hb=new il({}))},t,null);}},model:class extends zl{constructor(e,t,i,n){super(e,{layout:db||(db=new il({visibility:new Qs(nl.layout_model.visibility),"model-id":new el(nl.layout_model["model-id"]),"model-allow-density-reduction":new Qs(nl.layout_model["model-allow-density-reduction"])})),paint:fb||(fb=new il({"model-opacity":new el(nl.paint_model["model-opacity"]),"model-rotation":new el(nl.paint_model["model-rotation"]),"model-scale":new el(nl.paint_model["model-scale"]),"model-translation":new el(nl.paint_model["model-translation"]),"model-color":new el(nl.paint_model["model-color"]),"model-color-mix-intensity":new el(nl.paint_model["model-color-mix-intensity"]),"model-type":new Qs(nl.paint_model["model-type"]),"model-cast-shadows":new Qs(nl.paint_model["model-cast-shadows"]),"model-receive-shadows":new Qs(nl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Qs(nl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new el(nl.paint_model["model-emissive-strength"]),"model-roughness":new el(nl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new el(nl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Qs(nl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new Qs(nl.paint_model["model-front-cutoff"]),"model-elevation-reference":new Qs(nl.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new Qs(nl.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new el({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "Standard"===e}prepare(){return aA()}createBucket(e){return new xb(e)}getProgramIds(){return ["model"]}is3D(e){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e.isTiled3dModelBucket?8191:0}queryRenderedFeatures(e,t,i){return iA.queryModelLayerRendered?iA.queryModelLayerRendered(this,e,t,i):{}}queryIntersectsFeature(e,t,i,n,r,o,a,s,l,u){return !!iA.queryModelLayerIntersectsFeature&&iA.queryModelLayerIntersectsFeature(this,e,t,i,o,u)}_handleOverridablePaintPropertyUpdate(e,t,i){return !(!this.layout||t.isDataDriven()||i.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){const t=this._transitionablePaint._values[e];return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof Ga}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends zl{constructor(e,t,i,n){super(e,{layout:Ev||(Ev=new il({"clip-layer-types":new Qs(nl.layout_clip["clip-layer-types"]),"clip-layer-scope":new Qs(nl.layout_clip["clip-layer-scope"]),visibility:new Qs(nl.layout_clip.visibility)})),paint:Av||(Av=new il({}))},t,i,n);}recalculate(e,t){super.recalculate(e,t);}createBucket(e){return new Pv(e)}is3D(e){return !0}}};class lA{constructor(e){this.capacity=e,this.cache=new Map;}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,t);}delete(e){this.cache.delete(e);}}qa(lA,"LRUCache");class uA{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback();},0));}remove(){this._channel&&(this._channel.port1.close(),this._channel.port2.close()),this._callback=()=>{};}}const cA={Other:0,Symbol:1,FillExtrusion:2,HdRoadCoverage:3,HdRoadElevation:4};class hA{constructor(){this.tasks=new Map,ct(["process"],this),this.invoker=new uA(this.process),this.nextId=0;}add(e,t){const i=this.nextId++,n=function({type:e,renderSourceType:t,zoom:i}){i=i||0;const n=t===cA.Symbol;return "message"===e?0:"maybePrepare"!==e||n?"parseTile"!==e||n?"parseTile"===e&&n?300-i:"maybePrepare"===e&&n?400-i:500:200-i:100-i}(t);if(0===n){try{e();}finally{}return null}return this.tasks.set(i,{fn:e,metadata:t,priority:n,id:i}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(i);}}}process(){try{const e=this.pick();if(!e)return;this.tasks.delete(e.id),this.tasks.size>0&&this.invoker.trigger(),e.fn();}finally{}}pick(){let e=null,t=1/0;for(const i of this.tasks.values())i.priority<t&&(t=i.priority,e=i);return e}remove(){this.tasks.clear(),this.invoker.remove();}}const dA={type:"message"},fA=new Map,pA=new Map;class _A{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const i=this.toIdx(e,t);return {min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function mA(e,t,i,n){let r=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(n[a])<1e-15){if(i[a]<e[a]||i[a]>t[a])return null}else {const s=1/n[a];let l=(e[a]-i[a])*s,u=(t[a]-i[a])*s;if(l>u){const e=l;l=u,u=e;}if(l>r&&(r=l),u<o&&(o=u),r>o)return null}return r}function gA(e,t,i,n,r,o,a,s,l,u,c){const h=n-e,d=r-t,f=o-i,p=a-e,_=s-t,m=l-i,g=c[1]*m-c[2]*_,y=c[2]*p-c[0]*m,x=c[0]*_-c[1]*p,v=h*g+d*y+f*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=u[0]-e,E=u[1]-t,A=u[2]-i,I=(w*g+E*y+A*x)*b;if(I<0||I>1)return null;const T=E*f-A*d,M=A*h-w*f,S=w*d-E*h,z=(c[0]*T+c[1]*M+c[2]*S)*b;return z<0||I+z>1?null:(p*T+_*M+m*S)*b}function yA(e,t,i,n,r,o,a,s,l){const u=1<<i,c=o-n,h=a-r,d=(e+1)/u*c+n,f=(t+0)/u*h+r,p=(t+1)/u*h+r;s[0]=(e+0)/u*c+n,s[1]=f,l[0]=d,l[1]=p;}class xA{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=e.dim,i=Math.ceil(Math.log2(t/8)),n=[];let r=Math.ceil(Math.pow(2,i));const o=(e,t,i,n,r)=>{const o=n?1:0,a=(e+1)*i-o,s=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=s,r[2]=a,r[3]=l;};let a=new _A(r);const s=1/r,{floatView:l,stride:u}=e,c=[];for(let i=0;i<r*r;i++){const n=Math.floor(i/r),h=i%r;o(h,n,s,!1,c);const d=bA(c[0],c[1],e),f=bA(c[2],c[1],e),p=bA(c[2],c[3],e),_=bA(c[0],c[3],e),m=Math.min(d,f,p,_),g=Math.max(0,8*h-1),y=Math.min(t-1,8*(h+1)),x=Math.max(0,8*n-1),v=Math.min(t-1,8*(n+1));let b=-1/0;for(let e=x;e<=v;e++){const t=(e+1)*u;for(let e=g;e<=y;e++){const i=l[t+e+1];i>b&&(b=i);}}a.minimums.push(m),a.maximums.push(b),a.leaves.push(1);}for(n.push(a),r/=2;r>=1;r/=2){const e=n.at(-1);a=new _A(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,c);const i=e.getElevation(c[0],c[1]),n=e.getElevation(c[2],c[1]),s=e.getElevation(c[2],c[3]),l=e.getElevation(c[0],c[3]),u=e.isLeaf(c[0],c[1]),h=e.isLeaf(c[2],c[1]),d=e.isLeaf(c[2],c[3]),f=e.isLeaf(c[0],c[3]),p=Math.min(i.min,n.min,s.min,l.min),_=Math.max(i.max,n.max,s.max,l.max),m=u&&h&&d&&f;a.maximums.push(_),a.minimums.push(p),a.leaves.push(_-p<=5&&m?1:0);}n.push(a);}return n}(this.dem),i=t.length-1,n=t[i];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(t,0,0,i,0);}raycastRoot(e,t,i,n,r,o,a=1){return mA([e,t,-100],[i,n,this.maximums[0]*a],r,o)}raycast(e,t,i,n,r,o,a=1){if(!this.nodeCount)return null;const s=this.raycastRoot(e,t,i,n,r,o,a);if(null==s)return null;const l=[],u=[],c=[],h=[],d=[{idx:0,t:s,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:s,t:f,nodex:p,nodey:_,depth:m}=d.pop();if(this.leaves[s]){yA(p,_,m,e,t,i,n,c,h);const s=1<<m,l=p/s,u=(p+1)/s,d=_/s,g=(_+1)/s,{dim:y,floatView:x,stride:v}=this.dem,b=Math.floor(l*y),w=Math.ceil(u*y),E=Math.floor(d*y),A=w-b,I=Math.ceil(g*y)-E;if(A<=0||I<=0)continue;const T=c[0],M=c[1],S=(h[0]-T)/A,z=(h[1]-M)/I,R=Math.max(0,f),P=r[0]+o[0]*R,D=r[1]+o[1]*R,C=Math.abs(o[0])>1e-10,F=Math.abs(o[1])>1e-10,O=o[0]>=0?1:-1,L=o[1]>=0?1:-1;let B=Math.max(0,Math.min(A-1,Math.floor((P-T)/S))),N=Math.max(0,Math.min(I-1,Math.floor((D-M)/z)));const V=C?Math.abs(S/o[0]):Number.MAX_VALUE,k=F?Math.abs(z/o[1]):Number.MAX_VALUE;let G=C?R+(T+(o[0]>=0?B+1:B)*S-P)/o[0]:Number.MAX_VALUE,j=F?R+(M+(o[1]>=0?N+1:N)*z-D)/o[1]:Number.MAX_VALUE;const H=(e,t)=>x[(t+1)*v+e+1]*a;let $=H(b+B,E+N),Z=H(b+B+1,E+N),W=H(b+B,E+N+1),q=H(b+B+1,E+N+1),X=null;for(let e=0;e<A+I;e++){const e=Math.min(G,j);if(o[2]>=0||r[2]+o[2]*e<=Math.max($,Z,W,q)){const e=T+B*S,t=e+S,i=M+N*z,n=i+z,a=gA(t,i,Z,e,i,$,e,n,W,r,o),s=gA(e,n,W,t,n,q,t,i,Z,r,o);null!=a&&a>=0&&(null===X||a<X)&&(X=a),null!=s&&s>=0&&(null===X||s<X)&&(X=s);}const t=G<j;if(t?(B+=O,G+=V):(N+=L,j+=k),B<0||B>=A||N<0||N>=I)break;if(null!==X&&e>X)break;t?O>0?($=Z,W=q,Z=H(b+B+1,E+N),q=H(b+B+1,E+N+1)):(Z=$,q=W,$=H(b+B,E+N),W=H(b+B,E+N+1)):L>0?($=W,Z=q,W=H(b+B,E+N+1),q=H(b+B+1,E+N+1)):(W=$,q=Z,$=H(b+B,E+N),Z=H(b+B+1,E+N));}if(null!==X)return X||0;const Y=U([],r,o,f),J=(Y[0]-c[0])/(h[0]-c[0]),K=(Y[1]-c[1])/(h[1]-c[1]),Q=bA(l,d,this.dem)*a,ee=bA(u,d,this.dem)*a,te=bA(u,g,this.dem)*a;if(vA(Q,ee,bA(l,g,this.dem)*a,te,J,K)>=Y[2])return f;continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){yA((p<<1)+this._siblingOffset[d][0],(_<<1)+this._siblingOffset[d][1],m+1,e,t,i,n,c,h),c[2]=-100,h[2]=this.maximums[this.childOffsets[s]+d]*a;const f=mA(c,h,r,o);if(null!=f){const e=f;l[d]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[u[i]]&&(u.splice(i,0,d),t=!0);t||(u[g]=d),g++;}}for(let e=0;e<g;e++){const t=u[e];d.push({idx:this.childOffsets[s]+t,t:l[t],nodex:(p<<1)+this._siblingOffset[t][0],nodey:(_<<1)+this._siblingOffset[t][1],depth:m+1});}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=n-1,a=e[o];let s=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const n=2*t+this._siblingOffset[e][0],r=2*i+this._siblingOffset[e][1],o=a.getElevation(n,r),u=a.isLeaf(n,r),c=this._addNode(o.min,o.max,u);u&&(s|=1<<e),l||(l=c);}for(let n=0;n<this._siblingOffset.length;n++)s&1<<n||this._construct(e,2*t+this._siblingOffset[n][0],2*i+this._siblingOffset[n][1],o,l+n);}}function vA(e,t,i,n,r,o){return dn(dn(e,i,o),dn(t,n,o),r)}function bA(e,t,i){const n=i.dim,r=tt(e*n-.5,0,n-1),o=tt(t*n-.5,0,n-1),a=Math.floor(r),s=Math.floor(o),l=Math.min(a+1,n-1),u=Math.min(s+1,n-1);return vA(i.get(a,s),i.get(l,s),i.get(a,u),i.get(l,u),r-a,o-s)}const wA={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function EA(e,t,i){return (256*e*256+256*t+i)/10-1e4}function AA(e,t,i){return 256*e+t+i/256-32768}class IA{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void mt(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const r=this.dim=t.height-2,o=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(let e=0;e<r;e++)o[this._idx(-1,e)]=o[this._idx(0,e)],o[this._idx(r,e)]=o[this._idx(r-1,e)],o[this._idx(e,-1)]=o[this._idx(e,0)],o[this._idx(e,r)]=o[this._idx(e,r-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(r,-1)]=o[this._idx(r-1,0)],o[this._idx(-1,r)]=o[this._idx(0,r-1)],o[this._idx(r,r)]=o[this._idx(r-1,r-1)];}const a="terrarium"===i?AA:EA;for(let e=0;e<o.length;++e){const t=4*e;this.floatView[e]=a(this.pixels[t],this.pixels[t+1],this.pixels[t+2]);}this._timestamp=Vt.now();}_buildQuadTree(){this._tree=new xA(this);}get(e,t,i=!1){i&&(e=tt(e,-1,this.dim),t=tt(t,-1,this.dim));const n=this._idx(e,t);return this.floatView[n]}set(e,t,i){const n=this._idx(e,t),r=this.floatView[n];return this.floatView[n]=i,i-r}static getUnpackVector(e){return wA[e]}_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");return (t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],n=IA.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new cd({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(t){case -1:n=r-1;break;case 1:r=n+1;}switch(i){case -1:o=a-1;break;case 1:a=o+1;}const s=-t*this.dim,l=-i*this.dim;for(let t=o;t<a;t++)for(let i=n;i<r;i++){const n=4*this._idx(i,t),r=4*this._idx(i+s,t+l);this.pixels[n+0]=e.pixels[r+0],this.pixels[n+1]=e.pixels[r+1],this.pixels[n+2]=e.pixels[r+2],this.pixels[n+3]=e.pixels[r+3];}}onDeserialize(){this._tree&&(this._tree.dem=this);}}function TA(e,t){const i={};let n;for(;n=e.nextField(t);)1===n?(i.delta_filter=MA(e,e.readVarint()+e.pos),i.filter="delta_filter"):2===n?(e.readVarint(),i.filter="zigzag_filter"):3===n?(e.readVarint(),i.filter="bitshuffle_filter"):4===n&&(e.readVarint(),i.filter="byteshuffle_filter");return i}function MA(e,t){const i={blockSize:0};let n;for(;n=e.nextField(t);)1===n&&(i.blockSize=e.readVarint());return i}function SA(e,t){const i={};let n;for(;n=e.nextField(t);)1===n?(e.readVarint(),i.codec="gzip_data"):2===n?(e.readVarint(),i.codec="jpeg_image"):3===n?(e.readVarint(),i.codec="webp_image"):4===n&&(e.readVarint(),i.codec="png_image");return i}function zA(e,t){const i={firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]};let n,r=0,o=0;for(;n=e.nextField(t);)1===n?i.firstByte=e.readFixed64():2===n?i.lastByte=e.readFixed64():3===n?i.filters.push(TA(e,e.readVarint()+e.pos)):4===n?i.codec=SA(e,e.readVarint()+e.pos):5===n?o=e.readFloat():6===n?r=e.readFloat():7===n?i.bands.push(e.readString()):8===n?i.offset=e.readDouble():9===n&&(i.scale=e.readDouble());return 0===i.offset&&(i.offset=o),0===i.scale&&(i.scale=r),i}function RA(e,t){const i={version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]};let n;for(;n=e.nextField(t);)1===n?i.version=e.readVarint():2===n?i.name=e.readString():3===n?i.units=e.readString():4===n?i.tileSize=e.readVarint():5===n?i.buffer=e.readVarint():6===n?i.pixelFormat=e.readVarint():7===n&&i.dataIndex.push(zA(e,e.readVarint()+e.pos));return i}function PA(e,t,i){let n;for(;n=e.nextField(t);)if(1===n){let t=0;const n=e.readVarint()+e.pos;for(;e.pos<n;)i[t++]=e.readVarint();}return i}function DA(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n<t[0];n++){const a=t[1]*n;for(let n=r;n<t[1];n++){const r=t[2]*(n+a);for(let n=o;n<t[2];n++){const o=t[3]*(n+r);for(let n=0;n<t[3];n++){const t=o+n;e[t]+=e[t-i];}}}}i*=t[n];}return e}function CA(e){for(let t=0,i=e.length;t<i;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function FA(e,t){switch(t){case "uint32":return e;case "uint16":for(let t=0;t<e.length;t+=2){const i=e[t],n=e[t+1];e[t]=(240&i)>>4|(61440&i)>>8|(240&n)<<4|61440&n,e[t+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4;}return e;case "uint8":for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],r=e[t+2],o=e[t+3];e[t+0]=(192&i)>>6|(192&n)>>4|(192&r)>>2|192&o,e[t+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)<<2,e[t+2]=(12&i)>>2|12&n|(12&r)<<2|(12&o)<<4,e[t+3]=3&i|(3&n)<<2|(3&r)<<4|(3&o)<<6;}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}qa(IA,"DEMData"),qa(xA,"DemMinMaxQuadTree",{omit:["dem"]});var OA=Uint8Array,LA=Uint16Array,BA=Int32Array,NA=new OA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),VA=new OA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kA=new OA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),UA=function(e,t){for(var i=new LA(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new BA(i[30]);for(n=1;n<30;++n)for(var o=i[n];o<i[n+1];++o)r[o]=o-i[n]<<5|n;return {b:i,r}},GA=UA(NA,2),jA=GA.b,HA=GA.r;jA[28]=258,HA[258]=28;for(var $A=UA(VA,0).b,ZA=new LA(32768),WA=0;WA<32768;++WA){var qA=(43690&WA)>>1|(21845&WA)<<1;ZA[WA]=((65280&(qA=(61680&(qA=(52428&qA)>>2|(13107&qA)<<2))>>4|(3855&qA)<<4))>>8|(255&qA)<<8)>>1;}var XA=function(e,t,i){for(var n=e.length,r=0,o=new LA(t);r<n;++r)e[r]&&++o[e[r]-1];var a,s=new LA(t);for(r=1;r<t;++r)s[r]=s[r-1]+o[r-1]<<1;a=new LA(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],h=s[e[r]-1]++<<c,d=h|(1<<c)-1;h<=d;++h)a[ZA[h]>>l]=u;return a},YA=new OA(288);for(WA=0;WA<144;++WA)YA[WA]=8;for(WA=144;WA<256;++WA)YA[WA]=9;for(WA=256;WA<280;++WA)YA[WA]=7;for(WA=280;WA<288;++WA)YA[WA]=8;var JA=new OA(32);for(WA=0;WA<32;++WA)JA[WA]=5;var KA=XA(YA,9),QA=XA(JA,5),eI=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},tI=function(e,t,i){var n=t/8|0;return (e[n]|e[n+1]<<8)>>(7&t)&i},iI=function(e,t){var i=t/8|0;return (e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},nI=function(e){return (e+7)/8|0},rI=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],oI=function(e,t,i){var n=new Error(t||rI[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,oI),!i)throw n;return n},aI=new OA(0);var sI="undefined"!=typeof TextDecoder&&new TextDecoder;try{sI.decode(aI,{stream:!0});}catch(e){}const lI={gzip_data:"gzip"};class uI extends Error{constructor(e){super(e),this.name="MRTError";}}const cI={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},hI={uint32:1,uint16:2,uint8:4},dI={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let fI;class pI{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e;}getLayer(e){const t=this.layers[e];if(!t)throw new uI(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new uI("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length<i)throw new uI(`Expected header with length >= ${i} but got buffer of length ${t.length}`);const n=function(e){const t={headerLength:0,x:0,y:0,z:0,layers:[]};let i;for(;i=e.nextField(void 0);)1===i?t.headerLength=e.readFixed32():2===i?t.x=e.readVarint():3===i?t.y=e.readVarint():4===i?t.z=e.readVarint():5===i&&t.layers.push(RA(e,e.readVarint()+e.pos));return t}(new fI(t.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new uI(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new _I(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let n of e.blockIndices){const r=i.dataIndex[n],o=r.firstByte-e.firstByte,a=r.lastByte-e.firstByte;if(i._blocksInProgress.has(n))continue;const s={layerName:i.name,firstByte:o,lastByte:a,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map(e=>e.filter)};i._blocksInProgress.add(n),t.push(s);}return new mI(t,()=>{t.forEach(e=>i._blocksInProgress.delete(e.blockIndex));},(e,n)=>{if(t.forEach(e=>i._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e);});})}}class _I{constructor({version:e,name:t,units:i,tileSize:n,pixelFormat:r,buffer:o,dataIndex:a},s){if(this.version=e,1!==this.version)throw new uI(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=cI[r],this.dataIndex=a,this.bandShape=[n+2*o,n+2*o,hI[this.pixelFormat]],this._decodedBlocks=new lA(s?s.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return hI[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data);}getBlockForBand(e){let t=0;switch(typeof e){case "string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===e)return {bandIndex:t+r,blockIndex:i,blockBandIndex:r};t+=n.bands.length;}break;case "number":for(const[i,n]of this.dataIndex.entries()){if(e>=t&&e<t+n.bands.length)return {bandIndex:e,blockIndex:i,blockBandIndex:e-t};t+=n.bands.length;}break;default:throw new uI(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return {blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,i=-1/0;const n=[],r=new Set;for(const o of e){const{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new uI(`Invalid band: ${JSON.stringify(o)}`);const a=this.dataIndex[e];n.includes(e)||n.push(e),r.add(e),t=Math.min(t,a.firstByte),i=Math.max(i,a.lastByte);}if(r.size>this.cacheSize)throw new uI(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:t,lastByte:i,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e);if(t<0)throw new uI(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new uI(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[t],o=this.bandShape.reduce((e,t)=>e*t,1),a=i*o,s=n.subarray(a,a+o);return {data:s,bytes:new Uint8Array(s.buffer).subarray(s.byteOffset,s.byteOffset+s.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:r.offset,scale:r.scale}}}pI.setPbf=function(e){fI=e;};class mI{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0);}}pI.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:r,pixelFormat:o,blockShape:a,blockIndex:s,filters:l,codec:u}=e,c=i.subarray(n,r+1),h=new Uint32Array(a[0]*a[1]*a[2]);let d;if("gzip_data"!==u)throw new uI(`Unhandled codec: ${u}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((a=function(e){31==e[0]&&139==e[1]&&8==e[2]||oI(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(i=e),a+8>i.length&&oI(6,"invalid gzip data"),function(e,t,i,n){var r=e.length;if(!r||t.f&&!t.l)return i||new OA(0);var o=!i,a=o||2!=t.i,s=t.i;o&&(i=new OA(3*r));var l=function(e){var t=i.length;if(e>t){var n=new OA(Math.max(2*t,e));n.set(i),i=n;}},u=t.f||0,c=t.p||0,h=t.b||0,d=t.l,f=t.d,p=t.m,_=t.n,m=8*r;do{if(!d){u=tI(e,c,1);var g=tI(e,c+1,3);if(c+=3,!g){var y=e[(z=nI(c)+4)-4]|e[z-3]<<8,x=z+y;if(x>r){s&&oI(0);break}a&&l(h+y),i.set(e.subarray(z,x),h),t.b=h+=y,t.p=c=8*x,t.f=u;continue}if(1==g)d=KA,f=QA,p=9,_=5;else if(2==g){var v=tI(e,c,31)+257,b=tI(e,c+10,15)+4,w=v+tI(e,c+5,31)+1;c+=14;for(var E=new OA(w),A=new OA(19),I=0;I<b;++I)A[kA[I]]=tI(e,c+3*I,7);c+=3*b;var T=eI(A),M=(1<<T)-1,S=XA(A,T);for(I=0;I<w;){var z,R=S[tI(e,c,M)];if(c+=15&R,(z=R>>4)<16)E[I++]=z;else {var P=0,D=0;for(16==z?(D=3+tI(e,c,3),c+=2,P=E[I-1]):17==z?(D=3+tI(e,c,7),c+=3):18==z&&(D=11+tI(e,c,127),c+=7);D--;)E[I++]=P;}}var C=E.subarray(0,v),F=E.subarray(v);p=eI(C),_=eI(F),d=XA(C,p),f=XA(F,_);}else oI(1);if(c>m){s&&oI(0);break}}a&&l(h+131072);for(var O=(1<<p)-1,L=(1<<_)-1,B=c;;B=c){var N=(P=d[iI(e,c)&O])>>4;if((c+=15&P)>m){s&&oI(0);break}if(P||oI(2),N<256)i[h++]=N;else {if(256==N){B=c,d=null;break}var V=N-254;N>264&&(V=tI(e,c,(1<<(G=NA[I=N-257]))-1)+jA[I],c+=G);var k=f[iI(e,c)&L],U=k>>4;if(k||oI(3),c+=15&k,F=$A[U],U>3){var G=VA[U];F+=iI(e,c)&(1<<G)-1,c+=G;}if(c>m){s&&oI(0);break}a&&l(h+131072);var j=h+V;if(h<F){var H=0-F,$=Math.min(F,j);for(H+h<0&&oI(3);h<$;++h)i[h]=n[H+h];}for(;h<j;++h)i[h]=i[h-F];}}t.l=d,t.p=B,t.b=h,t.f=u,d&&(u=1,t.m=p,t.d=f,t.n=_);}while(!u);return h!=i.length&&o?function(e,t,i){return (null==i||i>e.length)&&(i=e.length),new OA(e.subarray(0,i))}(i,0,h):i.subarray(0,h)}(i.subarray(a,-8),{i:2},new OA(((r=i)[(o=r.length)-4]|r[o-3]<<8|r[o-2]<<16|r[o-1]<<24)>>>0),n)));var i,n,r,o,a;const s=lI[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(c,u).then(e=>(function(e,t){let i;for(;i=e.nextField();)if(2===i)PA(e,e.readVarint()+e.pos,t);else if(3===i)throw new Error("Not implemented")}(new fI(e),h),new(0,dI[o])(h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case "delta_filter":DA(e,a);break;case "zigzag_filter":CA(e);break;case "bitshuffle_filter":FA(e,o);break;default:throw new uI(`Unhandled filter "${l[t]}"`)}return {layerName:t,blockIndex:s,data:e}}).catch(e=>{throw e})}))},qa(mI,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),qa(pI,"MapboxRasterTile"),qa(_I,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const gI=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],yI=new Uint32Array(96);class xI{static from(e){if(!e||void 0===e.byteLength||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");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 n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=gI[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new xI(a,o,r,void 0,e)}constructor(e,t=64,i=Float64Array,n=ArrayBuffer,r){if(isNaN(e)||e<0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const o=gI.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${i}.`);if(r)this.data=r,this.ids=new this.IndexArrayType(r,8,e),this.coords=new i(r,8+s+l,2*e),this._pos=2*e,this._finished=!0;else {const r=this.data=new n(8+a+s+l);this.ids=new this.IndexArrayType(r,8,e),this.coords=new i(r,8+s+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(r,0,2).set([219,16+o]),new Uint16Array(r,2,1)[0]=t,new Uint32Array(r,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 vI(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:a}=this;yI[0]=0,yI[1]=r.length-1,yI[2]=0;let s=3;const l=[];for(;s>0;){const u=yI[--s],c=yI[--s],h=yI[--s];if(c-h<=a){for(let a=h;a<=c;a++){const s=o[2*a],u=o[2*a+1];s>=e&&s<=i&&u>=t&&u<=n&&l.push(r[a]);}continue}const d=h+c>>1,f=o[2*d],p=o[2*d+1];f>=e&&f<=i&&p>=t&&p<=n&&l.push(r[d]),(0===u?e<=f:t<=p)&&(yI[s++]=h,yI[s++]=d-1,yI[s++]=1-u),(0===u?i>=f:n>=p)&&(yI[s++]=d+1,yI[s++]=c,yI[s++]=1-u);}return l}within(e,t,i){const n=[];return this.withinInto(e,t,i,n),n}withinInto(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:a}=this;yI[0]=0,yI[1]=r.length-1,yI[2]=0;let s=3,l=0;const u=i*i;for(;s>0;){const c=yI[--s],h=yI[--s],d=yI[--s];if(h-d<=a){for(let i=d;i<=h;i++)AI(o[2*i],o[2*i+1],e,t)<=u&&(n[l++]=r[i]);continue}const f=d+h>>1,p=o[2*f],_=o[2*f+1];AI(p,_,e,t)<=u&&(n[l++]=r[f]),(0===c?e-i<=p:t-i<=_)&&(yI[s++]=d,yI[s++]=f-1,yI[s++]=1-c),(0===c?e+i>=p:t+i>=_)&&(yI[s++]=f+1,yI[s++]=h,yI[s++]=1-c);}return l}}function vI(e,t,i,n,r,o){if(r-n<=i)return;const a=n+r>>1;bI(e,t,a,n,r,o),vI(e,t,i,n,a-1,1-o),vI(e,t,i,a+1,r,1-o);}function bI(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const a=r-n+1,s=i-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);bI(e,t,i,Math.max(n,Math.floor(i-s*u/a+c)),Math.min(r,Math.floor(i+(a-s)*u/a+c)),o);}const a=t[2*i+o];let s=n,l=r;for(wI(e,t,n,i),t[2*r+o]>a&&wI(e,t,n,r);s<l;){for(wI(e,t,s,l),s++,l--;t[2*s+o]<a;)s++;for(;t[2*l+o]>a;)l--;}t[2*n+o]===a?wI(e,t,n,l):(l++,wI(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1);}}function wI(e,t,i,n){EI(e,i,n),EI(t,2*i,2*n),EI(t,2*i+1,2*n+1);}function EI(e,t,i){const n=e[t];e[t]=e[i],e[i]=n;}function AI(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}t.$=Jb,t.A=Fr,t.B=Lr,t.C=pn,t.D=Cr,t.E=sn,t.F=lr,t.G=nr,t.H=tr,t.I=ln,t.J=al,t.K=/^(.*)-transition$/,t.L=lA,t.M=Ra,t.N=Ma,t.O=De,t.P=Pe,t.Q=c,t.R=ai,t.S=Xf,t.T=p_,t.U=/^(.*)-use-theme$/,t.V=function(e,t){const i=Xf(t.zoom);if(0===i)return Of(e);const n=Vf(e),r=kf(n),o=hr(n.getWest())*t.worldSize,a=hr(n.getEast())*t.worldSize,s=dr(n.getNorth())*t.worldSize,l=dr(n.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=p([],t.globeMatrix);return Y(u,u,f),Y(c,c,f),Y(h,h,f),Y(d,d,f),r[0]=Lf(r[0],h,i),r[1]=Lf(r[1],d,i),r[2]=Lf(r[2],c,i),r[3]=Lf(r[3],u,i),zf.fromPoints(r)},t.W=$f,t.X=_,t.Y=u,t.Z=qb,t._=Hb,t.a=async function(e,t){e.headers||(e.headers={}),e.headers.accept="image/webp,*/*";const i=await function(e){return new Promise((t,i)=>{if(e&&e.aborted)return void i(e.reason);const n=()=>{const e=gi.shift();e?e():yi--;};if(yi<Ut.MAX_PARALLEL_IMAGE_REQUESTS)return yi++,void t(n);const r=()=>{e&&e.removeEventListener("abort",o),t(n);},o=()=>{const t=gi.indexOf(r);-1!==t&&gi.splice(t,1),i(e.reason);};e&&e.addEventListener("abort",o),gi.push(r);})}(t);try{const{data:i,headers:n}=await _i(e,t);let r;try{r=await createImageBitmap(new Blob([new Uint8Array(i)],{type:"image/png"}));}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`,{cause:e})}return t&&t.throwIfAborted(),{data:r,headers:n}}finally{i();}},t.a$=wc,t.a0=Iw,t.a1=Wb,t.a2=Sr,t.a3=Qc,t.a4=Kc,t.a5=rh,t.a6=eh,t.a7=hr,t.a8=dr,t.a9=z,t.aA=wu,t.aB=ap,t.aC=Ax,t.aD=Lx,t.aE=vw,t.aF=GE,t.aG=Gn,t.aH=(e,t,i,n,r,o,a,s,l,u,c,h,d,f,p,_,m,g,y=!1)=>{const x=BE(e,t,i,n,r,o,a,s,u,c,h,d,f,p,_,m,1,[0,0,0],[0,0,1],y),v={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return Object.assign(x,CE(t,l,g),v)},t.aI=BE,t.aJ=ux,t.aK=450,t.aL=7,t.aM=(e,t,i,n,r,o)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:n,u_height_type:FE[r],u_base_type:FE[o]}),t.aN=g,t.aO=p,t.aP=f,t.aQ=VE,t.aR=4,t.aS=2,t.aT=Lh,t.aU=Nh,t.aV=ct,t.aW=class{static calculate(e,t,i){const n=new Set,r=new Map,o=new Set,a=new Set;for(const i of Object.values(e))for(const[e,s]of Object.entries(i.floors)){o.add(e),s.isDefault&&a.add(e),s.conflicts&&r.set(e,s.conflicts);const i=e===t,l=s.connections&&t&&s.connections.has(t);(i||l)&&n.add(e);}const s=e=>{const t=r.get(e)||new Set;for(const i of n)if((r.get(i)||new Set).has(e)||t.has(i))return !0;return !1};if(i)for(const e of i)o.has(e)&&(s(e)||n.add(e));for(const e of a)n.has(e)||s(e)||n.add(e);return n}},t.aX=Jc,t.aY=ih,t.aZ=class extends Yc{constructor(e){super(e),this.current=new Float32Array(9);}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<9;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix3fv(this.location,!1,n);break}}},t.a_=Vu,t.aa=sc,t.ab=Cd,t.ac=Uc,t.ad=uc,t.ae=Ws,t.af=il,t.ag=Qs,t.ah=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return yt(e.expression.evaluate(t))}interpolate(e,t,i){return {x:dn(e.x,t.x,i),y:dn(e.y,t.y,i),z:dn(e.z,t.z,i),azimuthal:dn(e.azimuthal,t.azimuthal,i),polar:dn(e.polar,t.polar,i)}}},t.ai=Hs,t.aj=Ga,t.ak=Ks,t.al=dn,t.am=it,t.an=65,t.ao=45,t.ap=function(e,t,i){const n=Iu.fromLngLat(t),r=i.elevation?i.elevation.getAtPointOrZero(n):0;return Ew(e,n.x,n.y,r,i)},t.aq=function(e,t,i,n,r,o,a){const s=[[i,n,0],[r,n,0],[r,o,0],[i,o,0]];let l=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const e of s){const i=D(Y([],e,t));l=Math.min(l,i),u=Math.max(u,i);}return [ww(e,l,a.pitch),ww(e,u,a.pitch)]},t.ar=yn,t.as=Ew,t.at=bw,t.au=Ye,t.av=function(){return at++},t.aw=class{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.pendingResponses=new Map,ct(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new hA;}send(e,t,i){const{signal:n,targetMapId:r,metadata:o}=i||{},a=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=new Set;return n&&n.aborted?Promise.reject(n.reason):(this.target.postMessage({id:a,type:e,targetMapId:r,sourceMapId:this.mapId,data:Ka(t,s)},[...s]),new Promise((e,t)=>{const i={resolve:e,reject:t,metadata:o||dA};if(n){const e=()=>{this.pendingResponses.delete(a),t(n.reason);};n.addEventListener("abort",e,{once:!0}),i.detach=()=>n.removeEventListener("abort",e);}this.pendingResponses.set(a,i);}))}notify(e,t,i){const{targetMapId:n}=i||{},r=new Set;this.target.postMessage({type:e,targetMapId:n,sourceMapId:this.mapId,data:Ka(t,r)},[...r]);}sendCancelable(e,t,i,n){const r=new AbortController;return this.send(e,t,{...i,signal:r.signal}).then(e=>n(null,e)).catch(e=>{"AbortError"!==e.name&&n(e);}),r}getWorkerSourceActor(e){return {scheduler:this.scheduler,send:(t,i,n)=>this.send(t,i,{...n,targetMapId:e}),notify:(t,i)=>{this.notify(t,i,{targetMapId:e});},sendCancelable:(t,i,n,r)=>this.sendCancelable(t,i,{...n,targetMapId:e},r)}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(!t.targetMapId||this.mapId===t.targetMapId)if(vt(self)){const e=this.pendingResponses.get(i);this.scheduler.add(()=>{this.processTask(i,t);},e&&e.metadata||dA);}else this.processTask(i,t);}async processTask(e,t){if("<response>"===t.type){const i=this.pendingResponses.get(e);if(this.pendingResponses.delete(e),i){i.detach&&i.detach();try{t.error?i.reject(Qa(t.error)):i.resolve(Qa(t.data));}catch(e){i.reject(e);}}return}const i=new Set,n=Qa(t.data);try{let r;if(this.parent[t.type])r=await this.parent[t.type](t.sourceMapId,n);else {if(!this.parent.getWorkerSource)throw new Error(`Could not find function ${t.type}`);{const e=t.type.split("."),{source:i,scope:o}=n,a=this.parent.getWorkerSource(t.sourceMapId,{type:e[0],source:i,scope:o});r=await a[e[1]](n);}}if(!e)return;this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:null,data:Ka(r,i)},[...i]);}catch(t){this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:Ka(t),data:null},[]);}}remove(){for(const e of this.pendingResponses.values())e.detach&&e.detach(),e.reject(new DOMException("Actor removed","AbortError"));this.pendingResponses.clear(),this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}},t.ax=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const i=yt([1,e,t]);return {x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return {x:dn(e.x,t.x,i),y:dn(e.y,t.y,i),z:dn(e.z,t.z,i)}}},t.ay=iA,t.az=Sf,t.b=ud,t.b$=function(e,{x:t,y:i},n=0){return new Pe(((t-n)*e.scale-e.x)*Sr,(i*e.scale-e.y)*Sr)},t.b0=tt,t.b1=6,t.b2=Vf,t.b3=function(e){const t=80.051129;e=tt(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Ye(e))),3);return Math.round(i*(lu.length-1))},t.b4=Hf,t.b5=Of,t.b6=function(e){const t=e.pixelsPerMeter,i=t/yu(1,e.center.lat),n=d(new Float64Array(16));return m(n,n,[e.point.x,e.point.y,0]),g(n,n,[i,i,t]),Float32Array.from(n)},t.b7=function(e,t,i,n){const r=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),u=1<<e.z,c=l-a,h=r-o,d=c/su,f=-h/lu[i],p=[0,d,0,f,0,0,r,a,0];if(e.z>0){const e=180/n;s(p,p,[e/c+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/f,1]);}return p[2]=u,p[5]=e.x,p[8]=e.y,p},t.b8=Pt,t.b9=256,t.bA=bh,t.bB=Cu,t.bC=Uu,t.bD=xc,t.bE=xf,t.bF=Pl,t.bG=Uf,t.bH=Y,t.bI=Lf,t.bJ=Gu,t.bK=yf,t.bL=w,t.bM=m,t.bN=function(){js.isLoading()||js.isLoaded()||"deferred"!==Us()||Gs();},t.bO=li,t.bP=rp,t.bQ=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i},t.bR=cA,t.bS=Iu,t.bT=rt,t.bU="hd_road_coverage",t.bV=function(e){const t=e.indexOf(xl);return t>=0?e.slice(0,t):e},t.bW=bl,t.bX=ip,t.bY=np,t.bZ=function(e,t,i=0,n=!0){const r=new Pe(i,i),o=e.sub(r),a=t.add(r),s=[o,new Pe(a.x,o.y),a,new Pe(o.x,a.y)];return n&&s.push(o.clone()),s},t.b_=function(e,t){const i=[];for(let n=0;n<e.length;n++){const r=nt(n-1,-1,e.length-1),o=nt(n+1,-1,e.length-1),a=e[n],s=e[o],l=e[r].sub(a).unit(),u=s.sub(a).unit(),c=u.angleWithSep(l.x,l.y),h=l.add(u).unit().mult(-1*t/Math.sin(c/2));i.push(a.add(h));}return i},t.ba=xE,t.bb=RE,t.bc=gc,t.bd=ce,t.be=de,t.bf=pe,t.bg=T,t.bh=C,t.bi=fa,t.bj=fu,t.bk=mc,t.bl=_c,t.bm=xu,t.bn=yw,t.bo=Rt,t.bp=sp,t.bq=fr,t.br=pr,t.bs=ju,t.bt=Ic,t.bu=K_,t.bv=sl,t.bw=Fu,t.bx=Bb,t.by=bt,t.bz=gd,t.c=ka,t.c$=gw,t.c0=qh,t.c1=function(e,t,i=0){return C(((t.x-i)*e.scale-e.x)*Sr,(t.y*e.scale-e.y)*Sr,xu(t.z,t.y))},t.c2=te,t.c3=Z,t.c4=bf,t.c5=Bv,t.c6=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return {min:new Pe(t,i),max:new Pe(n,r)}},t.c7=le,t.c8=au,t.c9=Wh,t.cA=pI,t.cB=Zp,t.cC=_i,t.cD=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.cE=function(e,t,i,n,r,o,a){const s=ow(e,t,i,n,r,o,a);return "globe"===o.name&&i||(s[2]=s[6]=s[10]=s[14]=0),s},t.cF=function(e,t,i,n,r,o,a){if(i){if("globe"===o.name){const s=ow(e,t,i,n,r,o,a);return p(s,s),_(s,e,s),s}{const t=c(e),[i,o,s,l]=a,[u,h,d,f,p,_,m,g]=t;return t[0]=i*u+o*p,t[1]=i*h+o*_,t[2]=i*d+o*m,t[3]=i*f+o*g,t[4]=s*u+l*p,t[5]=s*h+l*_,t[6]=s*d+l*m,t[7]=s*f+l*g,n||v(t,t,-r.angle),t}}return r.glCoordMatrix},t.cG=of,t.cH=Dp,t.cI=ex,t.cJ=Up,t.cK=Gp,t.cL=qd,t.cM=Xd,t.cN=function(e,[t,i]){let n=0,r=0;if(i===af){t<0&&(t=0);const i=t/sf;switch(e){case "top-right":case "top-left":r=i-7;break;case "bottom-right":case "bottom-left":r=7-i;break;case "bottom":r=7-t;break;case "top":r=t-7;}switch(e){case "top-right":case "bottom-right":n=-i;break;case "top-left":case "bottom-left":n=i;break;case "left":n=t;break;case "right":n=-t;}}else {switch(t=Math.abs(t),i=Math.abs(i),e){case "top-right":case "top-left":case "top":r=i-7;break;case "bottom-right":case "bottom-left":case "bottom":r=7-i;}switch(e){case "top-right":case "bottom-right":case "right":n=-t;break;case "top-left":case "bottom-left":case "left":n=t;}}return [n,r]},t.cO=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.cP=Za,t.cQ=be,t.cR=Ie,t.cS=Ee,t.cT=ze,t.cU=nt,t.cV=oe,t.cW=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return !1;const i=t.getSource().maxzoom,n=1<<i,r=Math.floor(e.x),o=Math.floor((e.x-r)*n),a=Math.floor(e.y*n),s=this.findDEMTileFor(new rp(i,r,i,o,a));return !(!s||!s.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){if(this.isUsingMockSource())return null;t??=null;const n=this._source();if(!n)return t;if(e.y<0||e.y>1)return t;const r=n.getSource().maxzoom,o=1<<r,a=Math.floor(e.x),s=e.x-a,l=new rp(r,a,r,Math.floor(s*o),Math.floor(e.y*o)),u=this.findDEMTileFor(l);if(!u||!u.dem)return t;const c=u.dem,h=1<<u.tileID.canonical.z,d=(s*h-u.tileID.canonical.x)*c.dim,f=(e.y*h-u.tileID.canonical.y)*c.dim,p=Math.floor(d),_=Math.floor(f);return (i?this.exaggeration():1)*dn(dn(c.get(p,_),c.get(p,_+1),f-_),dn(c.get(p+1,_),c.get(p+1,_+1),f-_),d-p)}static getAtTileOffset(e,t,i,n){const r=1<<e.canonical.z;return n?n.pointElevation(t):i?i.getAtPointOrZero(new Iu(e.wrap+(e.canonical.x+t.x/Sr)/r,(e.canonical.y+t.y/Sr)/r)):0}static getAtTileOffsetFunc(e,t,i,n){return (r,o,a)=>{const s=this.getAtTileOffset(e,r,o,a),l=n.upVector(e.canonical,r.x,r.y);return k(l,l,s*n.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,n){if(this.isUsingMockSource())return !1;const r=vb.create(this,e,n);return !!r&&(t.forEach(e=>{e[2]=this.exaggeration()*r.getElevationAt(e[0],e[1],i,!0);}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,n=t.tileID,r=1<<e.canonical.z-n.canonical.z;let o=e.canonical.x/r-n.canonical.x,a=e.canonical.y/r-n.canonical.y,s=0;for(let t=0;t<e.canonical.z-n.canonical.z&&!i.leaves[s];t++){o*=2,a*=2;const e=2*Math.floor(a)+Math.floor(o);s=i.childOffsets[s]+e,o%=1,a%=1;}return {min:this.exaggeration()*i.minimums[s],max:this.exaggeration()*i.maximums[s]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,i=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const r of e){const e=this.getMinMaxForTile(r.tileID);e&&(i=Math.min(i,e.min),n=Math.max(n,e.max),t=!0);}return t?{min:i,max:n}:null}},t.cX=aw,t.cY=uw,t.cZ=id,t.c_=function(e,t,i,n,r,o){const a=[t,i,n];return Y(a,a,o.calculateFogTileMatrix(r)),ww(e,D(a),o.pitch)},t.ca=Mu,t.cb=ot,t.cc=class{constructor(e){this.entries={},this.scheduler=e;}request(e,t,i,n){const r=this.entries[e]=this.entries[e]||{callbacks:[]};if(r.result){const[e,i]=r.result;return this.scheduler?this.scheduler.add(()=>{n(e,i);},t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,n);},t):e(i,n);setTimeout(()=>delete this.entries[e],3e3);})),()=>{r.result||(r.callbacks=r.callbacks.filter(e=>e!==n),r.callbacks.length||(r.cancel(),delete this.entries[e]));}}},t.cd=function(e){if("provider"in e&&!e.provider)return null;let t=e.provider;if(!t&&"url"in e&&e.url&&(t=function(e){try{const t=new URL(e).pathname.split("/").pop()||"",i=t.lastIndexOf(".");return i>=0?t.slice(i+1):""}catch{return ""}}(e.url)),!t)return null;const i=Ut.TILE_PROVIDER_URLS[t];if(!i)return null;let n;try{n=new URL(i,Ut.API_URL).href;}catch(e){return new Error(`TileProvider "${t}" has an invalid URL: "${i}"`)}return {name:t,url:n}},t.ce=QE,t.cf=tA,t.cg=ii,t.ch=function(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom},t=>{const n=new AbortController;return _i(e.request,n.signal).then(({data:e,headers:n})=>{t(null,{rawData:e,vectorTile:i?void 0:new Oh(new Zp(e)),headers:n});}).catch(e=>{n.signal.aborted||(li(e)?t(null,null):t(e));}),()=>{n.abort(),t(null,null);}},t)},t.ci=wt,t.cj=function(e){ei++,ei>Xt&&(e.getActor().notify("enforceCacheSizeLimit",qt),ei=0);},t.ck=Ui,t.cl=async function(e,t,i){const n=e.url&&!e.tiles?await t.transformRequest(e.url,ai.Source,i):void 0;return {request:n,options:n?{...e,url:n.url}:e}},t.cm=function(e,t,i){return t?KE(e,t,i):e.tiles&&e.tiles.length>0?{tiles:e.tiles}:new Error('TileJSON is missing required "tiles" property')},t.cn=async function(e,t){const i=pA.get(e);if(i)return i;const n=fA.get(e);if(void 0!==n)return n;const r=self.__mapboxImport(
/* webpackIgnore: true */
/* @vite-ignore */
t).catch(t=>{throw new Error(`TileProvider "${e}" failed to load: ${t instanceof Error?t.message:String(t)}`)}).then(t=>{const i=t.default;if("function"!=typeof i)throw new Error(`TileProvider "${e}" module must default-export a class`);if("function"!=typeof i.prototype.loadTile)throw new Error(`TileProvider "${e}" class must have a loadTile method`);return pA.set(e,i),i}).finally(()=>{fA.delete(e);});return fA.set(e,r),r},t.co=class{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}},t.cp=vu,t.cq=function(e,t,i,n){for(;t<i;){const r=t+i>>1;e[r]<=n?t=r+1:i=r;}return t},t.cr=function(e,t,i,n){for(;t<i;){const r=t+i>>1;e[r]<n?t=r+1:i=r;}return t},t.cs=su,t.ct=J,t.cu=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=r*u-n*c,e[2]=n*s-r*a,e[3]=s*l-o*c,e[4]=i*c-r*l,e[5]=r*o-i*s,e[6]=o*u-a*l,e[7]=n*l-i*u,e[8]=i*a-n*o,e},t.cv=s,t.cw=async function(e){const t=document.createElement("video");t.muted=!0;for(const i of e){const e=document.createElement("source");mi(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e);}return await new Promise((i,n)=>{t.onloadstart=()=>i(),t.onerror=()=>n(new Error(`Could not load video: ${e.join(", ")}`));}),t},t.cx=ab,t.cy=pb,t.cz=_u,t.d=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures();});}beginFrame(){this.currentFrameAtlases.clear();}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const i=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=i,e.uploaded=!1;}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[i]of this.textures.entries()){if(this.currentFrameAtlases.has(i))continue;const n=this.textureAccessTimes.get(i)||0;n<t&&(t=n,e=i);}if(!e)break;this.evictTexture(e);}}findCachedAtlas(e){const t=this.cache.get(e.hash);if(t){const i=t.deref();if(i&&i.contentDescriptor&&this.isMipmapCompatible(e,i.contentDescriptor))return i}for(const[,t]of this.cache.entries()){const i=t.deref();if(i&&i.contentDescriptor){const t=e.subsetOf(i.contentDescriptor),n=this.isMipmapCompatible(e,i.contentDescriptor);if(t&&n)return i}}}getTextureForAtlas(e,t,i){this.textureAccessTimes.set(e,performance.now()),this.currentFrameAtlases.add(e);let n=this.textures.get(e);if(n)return n;if(e.image){const r=this.calculateTextureMemory(e);return this.evictTexturesIfNeeded(r),n=new p_(t,e.image,i,{useMipmap:!!e.patternPositions.size}),this.textures.set(e,n),this.textureMemoryUsed+=r,n}return null}clearExpiredTextures(){for(const[e]of this.textures.entries())if(!this.isAtlasCached(e)){const t=this.textures.get(e);if(t){const i=this.calculateTextureMemory(e);t.destroy(),this.textureMemoryUsed-=i;}this.textures.delete(e),this.textureAccessTimes.delete(e);}}isAtlasCached(e){if(!e.contentDescriptor)return !1;const t=this.cache.get(e.contentDescriptor.hash);return !!t&&t.deref()===e}getOrCache(e){if(!("image"in e)){const t=this.cache.get(e.sourceAtlasHash);if(t){const e=t.deref();if(e)return e}return mt("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!e.contentDescriptor)return e;const t=e.contentDescriptor,i=t.hash,n=this.cache.get(i);if(n){const e=n.deref();if(e&&e.contentDescriptor&&this.isMipmapCompatible(t,e.contentDescriptor))return e}return this.cache.set(i,new WeakRef(e)),this.finalizationRegistry.register(e,i,e),e}isMipmapCompatible(e,t){return !e.requiresMipMaps||t.requiresMipMaps}destroyTextures(){for(const e of this.textures.values())e&&e.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0;}clear(){for(const e of this.textures.values())e&&e.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0;}},t.d$=W_,t.d0=d,t.d1=Zd,t.d2=.9,t.d3=re,t.d4=rf,t.d5=xI,t.d6=function(e){return e({pluginStatus:Ls,pluginURL:Bs}),ks.on("pluginStateChange",e),e},t.d7=ui,t.d8=R_,t.d9=z_,t.dA=U,t.dB=function(e,t){return [Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},t.dC=k,t.dD=O,t.dE=Tt,t.dF=W,t.dG=IE,t.dH=TE,t.dI=e=>({u_cutoff_params:new ih(e)}),t.dJ=e=>({u_light_matrix_0:new rh(e),u_light_matrix_1:new rh(e),u_fade_range:new Qc(e),u_shadow_normal_offset:new eh(e),u_shadow_intensity:new Kc(e),u_shadow_texel_size:new Kc(e),u_shadow_map_resolution:new Kc(e),u_shadow_direction:new eh(e),u_shadow_bias:new eh(e),u_shadowmap_0:new Jc(e),u_shadowmap_1:new Jc(e)}),t.dK=CE,t.dL=Wf,t.dM=rb,t.dN=Mt,t.dO=St,t.dP=function(e,t){const i=[0,0,0];return Y(i,i,Hf(Of(t.canonical))),Y(i,i,e),i},t.dQ=Nb,t.dR=function(e,t,i,n,r,o){const{width:a,height:s}=n.imageManager.getPixelSize(t),l=Math.pow(2,o.tileID.overscaledZ),u=o.tileSize*Math.pow(2,n.transform.tileZoom)/l,c=u*(o.tileID.canonical.x+o.tileID.wrap*l),h=u*o.tileID.canonical.y;return {u_image:0,u_pattern_tl:i.tl,u_pattern_br:i.br,u_texsize:[a,s],u_pattern_size:i.displaySize,u_pattern_units_to_pixels:r?[n.transform.width,-1*n.transform.height]:[1/Bv(o,1,n.transform.tileZoom),1/Bv(o,1,n.transform.tileZoom)],u_pixel_coord_upper:[c>>16,h>>16],u_pixel_coord_lower:[65535&c,65535&h]}},t.dS=e=>({u_matrix:new rh(e),u_texsize:new Qc(e),u_pixels_to_tile_units:new oh(e),u_device_pixel_ratio:new Kc(e),u_width_scale:new Kc(e),u_floor_width_scale:new Kc(e),u_image:new Jc(e),u_units_to_pixels:new Qc(e),u_tile_units_to_pixels:new Kc(e),u_alpha_discard_threshold:new Kc(e),u_trim_offset:new Qc(e),u_trim_fade_range:new Qc(e),u_trim_gradient_mix_range:new Qc(e),u_trim_color:new ih(e),u_zbias_factor:new Kc(e),u_tile_to_meter:new Kc(e),u_ground_shadow_factor:new eh(e),u_pattern_transition:new Kc(e),u_opacity_multiplier:new Kc(e)}),t.dT=e=>({u_matrix:new rh(e),u_pixels_to_tile_units:new oh(e),u_device_pixel_ratio:new Kc(e),u_width_scale:new Kc(e),u_floor_width_scale:new Kc(e),u_units_to_pixels:new Qc(e),u_dash_image:new Jc(e),u_gradient_image:new Jc(e),u_border_gradient_image:new Jc(e),u_image_height:new Kc(e),u_texsize:new Qc(e),u_tile_units_to_pixels:new Kc(e),u_alpha_discard_threshold:new Kc(e),u_trim_offset:new Qc(e),u_trim_fade_range:new Qc(e),u_trim_gradient_mix_range:new Qc(e),u_trim_color:new ih(e),u_zbias_factor:new Kc(e),u_road_view_depth_bias:new Kc(e),u_road_clip_to_view:new ih(e),u_tile_to_meter:new Kc(e),u_ground_shadow_factor:new eh(e),u_opacity_multiplier:new Kc(e)}),t.dU=e=>({u_color:new nh(e),u_matrix:new rh(e),u_overlay:new Jc(e),u_overlay_scale:new Kc(e)}),t.dV=e=>({u_camera_to_center_distance:new Kc(e),u_extrude_scale:new oh(e),u_device_pixel_ratio:new Kc(e),u_matrix:new rh(e),u_inv_rot_matrix:new rh(e),u_merc_center:new Qc(e),u_tile_id:new eh(e),u_zoom_transition:new Kc(e),u_up_dir:new eh(e),u_emissive_strength:new Kc(e)}),t.dW=e=>({u_matrix:new rh(e),u_lightpos:new eh(e),u_lightintensity:new Kc(e),u_lightcolor:new eh(e),u_vertical_gradient:new Kc(e),u_height_factor:new Kc(e),u_edge_radius:new Kc(e),u_width_scale:new Kc(e),u_ao:new Qc(e),u_height_type:new Jc(e),u_base_type:new Jc(e),u_tile_id:new eh(e),u_zoom_transition:new Kc(e),u_inv_rot_matrix:new rh(e),u_merc_center:new Qc(e),u_up_dir:new eh(e),u_height_lift:new Kc(e),u_image:new Jc(e),u_texsize:new Qc(e),u_pixel_coord_upper:new Qc(e),u_pixel_coord_lower:new Qc(e),u_tile_units_to_pixels:new Kc(e),u_opacity:new Kc(e),u_pattern_transition:new Kc(e)}),t.dX=e=>({u_matrix:new rh(e),u_lightpos:new eh(e),u_lightintensity:new Kc(e),u_lightcolor:new eh(e),u_vertical_gradient:new Kc(e),u_opacity:new Kc(e),u_edge_radius:new Kc(e),u_width_scale:new Kc(e),u_ao:new Qc(e),u_height_type:new Jc(e),u_base_type:new Jc(e),u_tile_id:new eh(e),u_zoom_transition:new Kc(e),u_inv_rot_matrix:new rh(e),u_merc_center:new Qc(e),u_up_dir:new eh(e),u_height_lift:new Kc(e),u_flood_light_color:new eh(e),u_vertical_scale:new Kc(e),u_flood_light_intensity:new Kc(e),u_ground_shadow_factor:new eh(e),u_front_cutoff_params:new eh(e)}),t.dY=ow,t.dZ=mw,t.d_=sw,t.da=Ns,t.db=Zt,t.dc=tn,t.dd=ft,t.de=xt,t.df=function(e){return e.includes(xl)},t.dg=function(e){const t=e.lastIndexOf(xl);return t>=0?e.slice(t+1):""},t.dh=function(e,t={}){const i=t.type&&!t.array&&Array.isArray(e)?{type:t.type,"property-type":"data-constant"}:void 0;return ka(null===e||"object"!=typeof e||Array.isArray(e)?e:["literal",e],i)},t.di=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},t.dj=function(e,t,i,n){return "custom"===e.type?new _b(e,t):new sA[e.type](e,t,i,n)},t.dk=dt,t.dl=class extends Bb{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state={...e.state}),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer);}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},t.dm=ks,t.dn=UE,t.dp=function(){return {API_URL:Ut.API_URL,DRACO_URL:Ut.DRACO_URL,MESHOPT_URL:Ut.MESHOPT_URL,MESHOPT_SIMD_URL:Ut.MESHOPT_SIMD_URL,BUILDING_GEN_URL:Ut.BUILDING_GEN_URL}},t.dq=nh,t.dr=S,t.ds=Qe,t.dt=function(e,t,i){const n=Xf(i.zoom),r=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.du=function(e,t,i){const n=d(new Float64Array(16)),r=(t/(1<<e)-.5)*Math.PI*2;return x(n,i.globeMatrix,r),Float32Array.from(n)},t.dv=cd,t.dw=yu,t.dx=Rf,t.dy=ae,t.dz=L,t.e=Vt,t.e$=Ki,t.e0=function(e,t,i,n,r,o,a,s,l,u,c=1){const h=i.transform,d=n?e.textSizeData:e.iconSizeData,f=of(d,i.transform.zoom,c),p="globe"===h.projection.name,_=(()=>{if(!p)return null;const e=Xf(h.zoom);return 0===e?null:{t:e,invMatrix:h.projection.createInversionMatrix(h,u.canonical),mercCenter:[hr(h.center.lng),dr(h.center.lat)]}})(),m=[256/i.width*2+1,256/i.height*2+1],g=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let y=null;p&&(y=n?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const x=e.lineVertexArray,v=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let w,E=!1;for(let c=0;c<v.length;c++){const p=v.get(c),{numGlyphs:A,writingMode:I}=p;if(I!==qd.vertical||E||w===qd.horizontal||(E=!0),w=I,(p.hidden||I===qd.vertical)&&!E){mw(A,g);continue}E=!1;const T=new Pe(p.tileAnchorX,p.tileAnchorY),M="road"===e.elevationType,S=!!h.elevation||M;let{x:z,y:R,z:P}=h.projection.projectTilePoint(T.x,T.y,u.canonical);if(_){const[e,t,i]=dw(T,u.canonical,_);z+=(e-z)*_.t,R+=(t-R)*_.t,P+=(i-P)*_.t;}let D=null;if(S){D=M&&e.hdExt?e.hdExt.makeRoadSymbolElevationParams(e,n?e.text:e.icon,c,u,l,h.elevation,h.projection,h.center.lat,h.worldSize):{getElevation:l,elevation:h.elevation,elevationFeature:null};const[t,i,r]=D.getElevation(T,h.elevation,D.elevationFeature);z+=t,R+=i,P+=r;}const C=[z,R,P,1];if(le(C,C,t),!lw(C,m)){mw(A,g);continue}const F=C[3],O=sw(i.transform.getCameraToCenterDistance(h.projection),F),L=rf(d,f,p),B=a?L/O:L*O,N=aw(z,R,P,r);if(N[3]<=0){mw(A,g);continue}let V={};const k=Ye(e.layers[0].layout.get("text-max-angle")),U=Math.cos(k),G=a?null:D,j=hw(p,B,!1,s,t,r,o,e.glyphOffsetArray,x,g,y,N,T,V,b,G,h.projection,u,a,U,_);E=j.useVertical,G&&j.needsFlipping&&(V={}),(j.notEnoughRoom||E||j.needsFlipping&&hw(p,B,!0,s,t,r,o,e.glyphOffsetArray,x,g,y,N,T,V,b,G,h.projection,u,a,U,_).notEnoughRoom)&&mw(A,g);}n?(e.text.dynamicLayoutVertexBuffer.updateData(g),y&&e.text.globeExtVertexBuffer&&e.text.globeExtVertexBuffer.updateData(y)):(e.icon.dynamicLayoutVertexBuffer.updateData(g),y&&e.icon.globeExtVertexBuffer&&e.icon.globeExtVertexBuffer.updateData(y));},t.e1=__,t.e2=lv,t.e3=(e,t,i,n,r,o)=>{const a=e.transform,s="globe"===a.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(s){const e=Wf(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=a.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Vt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:sv,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(s){u.u_inv_rot_matrix=n,u.u_merc_center=r,u.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],u.u_zoom_transition=Xf(a.zoom);const e=r[0]*Sr,i=r[1]*Sr;u.u_up_dir=a.projection.upVector(new ip(0,0,0),e,i);}return u},t.e4=kv,t.e5=(e,t,i,n,r,o,a,s,l,u)=>{const c=e.transform,h=c.pitch<15?dn(.07,.7,tt((14-c.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return {u_matrix:Vv(e,t,i,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:r,u_width_scale:o,u_floor_width_scale:a,u_image:0,u_tile_units_to_pixels:Nv(t,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:Au(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:u,u_opacity_multiplier:1}},t.e6=(e,t,i,n,r,o,a,s,l,u)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),f=c.pitch<15?dn(.07,.7,tt((14-c.zoom)/5,0,1)):.07;return {u_matrix:Vv(e,t,i,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:a,u_floor_width_scale:s,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_border_gradient_image:2,u_image_height:r,u_texsize:Uv(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Nv(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:f,u_road_view_depth_bias:0,u_road_clip_to_view:[0,0,0,0],u_tile_to_meter:Au(t.tileID.canonical,0),u_ground_shadow_factor:u,u_opacity_multiplier:1}},t.e7=lt,t.e8=yv,t.e9=5,t.eA=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},t.eB=ie,t.eC=mu,t.eD=du,t.eE=q,t.eF=zf,t.eG=H,t.eH=F,t.eI=function([e,t,i]){const n=Math.hypot(e,t,i),r=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/n);return new _u(Je(r),Je(o))},t.eJ=G,t.eK=se,t.eL=iy,t.eM=Ut,t.eN=bi,t.eO=vi,t.eP=xw,t.eQ=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",xi,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}async transformRequest(e,t,i){if(!this._transformRequestFn)return {url:e};const n=i?{signal:i}:{};return await this._transformRequestFn(e,t,n)||{url:e}}normalizeStyleURL(e,t){if(!ii(e))return e;const n=Ri(e);return n.params.push(`sdk=js-${i}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!ii(e))return e;const i=Ri(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!ii(e))return e;const i=Ri(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,n){if(!ii(e))return e;const r=Ri(e);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||t)}normalizeIconsetURL(e,t){const i=Ri(e);return ii(e)?(i.path=`/styles/v1${i.path}/iconset.pbf`,this._makeAPIURL(i,this._customAccessToken||t)):Pi(i)}normalizeSpriteURL(e,t,i,n){const r=Ri(e);return ii(e)?(r.path=`/styles/v1${r.path}/sprite${t}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${t}${i}`,Pi(r))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!ii(e))return e;const n=Ri(e);n.path=n.path.replace(Ei,(t||i&&"raster"!==n.authority&&512===i?"@2x":"")+".webp"),"raster"===n.authority?n.path=`/${Ut.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${Ut.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${Ut.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(Ai,"/"),n.path=`/${Ut.TILE_URL_VERSION}${n.path}`);const r=this._customAccessToken||function(e){for(const t of e){const e=t.match(Mi);if(e)return e[1]}return null}(n.params)||Ut.ACCESS_TOKEN;return Ut.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,r)}canonicalizeTileURL(e,t){const i=Ri(e);if(!Ti.test(i.path)||!Ii.test(i.path))return e;let n="mapbox://";i.path.startsWith("/raster/v1/")?n+=`raster/${i.path.replace(`/${Ut.RASTER_URL_PREFIX}/`,"")}`:i.path.startsWith("/rasterarrays/v1/")?n+=`rasterarrays/${i.path.replace(`/${Ut.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${Ut.TILE_URL_VERSION}/`,"")}`;let r=i.params;return t&&(r=r.filter(e=>!e.match(Mi))),r.length&&(n+=`?${r.join("&")}`),n}canonicalizeTileset(e,t){const i=!!t&&ii(t),n=[];for(const t of e.tiles||[])ti(t)?n.push(this.canonicalizeTileURL(t,i)):n.push(t);return n}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=Ri(Ut.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1);}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!Ut.REQUIRE_ACCESS_TOKEN)return Pi(e);if(t=t||Ut.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(e=>!e.includes("access_token")),e.params.push(`access_token=${t||""}`),Pi(e)}},t.eR=Ci,t.eS=function(e,t){t?en.add(e):en.delete(e);},t.eT=Ji,t.eU=Qi,t.eV=Si,t.eW=ji,t.eX=$i,t.eY=Wi,t.eZ=Xi,t.e_=function(e){en.delete(e);},t.ea=ob,t.eb=Yu,t.ec=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-i,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=i,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.ed=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=i,e[7]=0,e[8]=0,e[9]=-i,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.ee=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},t.ef=a,t.eg=fc,t.eh=1,t.ei=Zb,t.ej=0,t.ek=pc,t.el=function(e,t,i,n,r){return tt((e-t)/(i-t)*(r-n)+n,n,r)},t.em=D,t.en=fe,t.eo=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,d=-c*o+s*l,f=u*o-a*l,p=i*h+n*d+r*f;return p?(e[0]=h*(p=1/p),e[1]=(-c*n+r*u)*p,e[2]=(s*n-r*a)*p,e[3]=d*p,e[4]=(c*i-r*l)*p,e[5]=(-s*i+r*o)*p,e[6]=f*p,e[7]=(-u*i+n*l)*p,e[8]=(a*i-n*o)*p,e):null},t.ep=rc,t.eq=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Pe(1/0,1/0),max:new Pe(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=Bp(new Pe(0,0),new Pe(Sr,Sr),e),n=[];if(t&&!Op(i,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Op(i,t))continue;const r=Np(t.min,t.max,e);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope});}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(i).buckets[e.layer];n&&n.updateFootprints(i.toUnwrapped(),t);}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})));}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),n=e.getClipMask(),r=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Bp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:i,clipMask:n,clipScope:r});}this._sourceIds.push(e.getSourceId());}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Cp(e.min,t.min)||Cp(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[t];e=i.priority!==n.priority||!Fp(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!De(i.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t;}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Rp&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e<t.length&&t[e].priority===i;)++e;return e};if(this._sourceIds.length>1){let t=0,i=e(t);for(;t!==i;){let n=t;const r=t;for(;n!==i;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t<r;t++){const i=this._activeRegions[t];if(!i.hiddenByOverlap&&e.order===Rp&&Op(e,i)&&(e.hiddenByOverlap=kp(e.footprint,e.tileId,i.footprint,i.tileId),e.hiddenByOverlap))break}++n;}t=i,i=e(t);}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement();}},t.er=Rp,t.es=class{constructor(e){this._createGrid(e),this._createPoles(e);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy();}_fillGridMeshWithLods(e,t){const i=new Uu,n=new uc,r=[],o=e+1+2,a=t[0]+1,s=t[0]+1+(1+t.length),l=(e,t,i)=>{let n=e===o-1?e-2:0===e?e:e-1;return n+=i?24575:0,[n,t]};for(let e=0;e<o;++e)i.emplaceBack(...l(e,0,!0));for(let e=0;e<a;++e)for(let t=0;t<o;++t)i.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const n=t[e];for(let e=0;e<o;++e)i.emplaceBack(...l(e,n,!0));}for(let e=0;e<t.length;++e){const a=n.length,l=t[e]+1+2,u=new uc;for(let i=0;i<l-1;i++){const r=i===l-2,a=r?o*(s-t.length+e-i):o;for(let e=0;e<o-1;e++){const t=i*o+e;0===i||r||0===e||e===o-2?(u.emplaceBack(t+1,t,t+a),u.emplaceBack(t+a,t+a+1,t+1)):(n.emplaceBack(t+1,t,t+a),n.emplaceBack(t+a,t+a+1,t+1));}}const c=Uc.simpleSegment(0,a,i.length,n.length-a);for(let e=0;e<u.uint16.length;e+=3)n.emplaceBack(u.uint16[e],u.uint16[e+1],u.uint16[e+2]);const h=Uc.simpleSegment(0,a,i.length,n.length-a);r.push({withoutSkirts:c,withSkirts:h});}return {vertices:i,indices:n,segments:r}}_createGrid(e){const t=this._fillGridMeshWithLods(su,lu);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,xf.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0);}_createPoles(e){const t=new uc;for(let e=0;e<=su;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new fc,n=new fc,r=new fc,o=new fc;this._poleSegments=[];for(let e=0,t=0;e<6;e++){const a=360/(1<<e);i.emplaceBack(0,-au,0,.5,0),n.emplaceBack(0,-au,0,.5,1),r.emplaceBack(0,-au,0,.5,.5),o.emplaceBack(0,-au,0,.5,.5);for(let e=0;e<=su;e++){let t=e/su,s=0;const l=dn(0,a,t),[u,c,h]=hu(Qf,ep,l,au);i.emplaceBack(u,c,h,t,s),n.emplaceBack(u,c,h,t,1-s);const d=Ye(l);t=.5+.5*Math.sin(d),s=.5+.5*Math.cos(d),r.emplaceBack(u,c,h,t,s),o.emplaceBack(u,c,h,t,1-s);}this._poleSegments.push(Uc.simpleSegment(t,0,66,64)),t+=66;}this._poleNorthVertexBuffer=e.createVertexBuffer(i,gf,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(n,gf,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(r,gf,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,gf,!1);}getGridBuffers(e,t){return [this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return [t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},t.et=function(e){return en.has(e)},t.eu=ME,t.ev=Pp,t.ew=Re,t.ex=function(){return !!document.fullscreenElement||!!document.webkitFullscreenElement},t.ey=et,t.ez=Eu,t.f=rn,t.f$=nf,t.f0=Gi,t.f1=function(e,t){qt=e,Xt=t;},t.f2=i,t.f3=Jf,t.f4=Je,t.f5=Yf,t.f6=function(e){const t=[0,0,0],i=d(new Float64Array(16));return _(i,e.pixelMatrix,e.globeMatrix),Y(t,t,i),new Pe(t[0],t[1])},t.f7=function(e){Bi=e;},t.f8=ni,t.f9=iw,t.fA=nA,t.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Og){const i=new Uint32Array(e,0,7),[,,n,r,o,a]=i;t=i.byteLength+r+o+a+o,(n!==e.byteLength||t>=e.byteLength)&&mt("Invalid b3dm header information.");}return Ug(e,t)},t.fC=function(e,t){const i=e.json.extensionsUsed&&e.json.extensionsUsed.includes("mbx_bvh"),n=Dy(e);for(const e of n){if(!i)for(const t of e.meshes)Cy(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(Oy(e.lights,t)));}return n},t.fD=Au,t.fE=zb,t.fF=qa,t.fG=function(e,t){let i="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n+1)||null,o=e.charCodeAt(n-1)||null;i+=!t&&(r&&Rs(r)&&!Kd[e[n+1]]||o&&Rs(o)&&!Kd[e[n-1]])||!Kd[e[n]]?e[n]:Kd[e[n]];}return i},t.fH=js,t.fI=function(e){return !(e<11904||!(cs(e)||us(e)||Es(e)||vs(e)||ps(e)||ns(e)||hs(e)||as(e)||_s(e)||ms(e)||fs(e)||Ts(e)||ss(e)||os(e)||rs(e)||ds(e)||ls(e)||ws(e)||ys(e)||gs(e)))},t.fJ=zs,t.fK=function(e){return es(e)||ts(e)||is(e)||bs(e)||Is(e)},t.fL=function(e){return 12307===e||12312===e||12313===e||12316===e||12448===e||12540===e||e>=8592&&e<=8595||8208===e||8229===e||8741===e||e>=9472&&e<=9547||65294===e||65309===e||65374===e||65507===e},t.fM=3,t.fN=Mr,t.fO=$h,t.fP=dd,t.fQ=function(e){for(const t of e)if(!Ss(t.charCodeAt(0)))return !1;return !0},t.fR=Ms,t.fS=ff,t.fT=Yd,t.fU=pf,t.fV=Jd,t.fW=g_,t.fX=1,t.fY=cf,t.fZ=hf,t.f_=Ne,t.fa=function(e,t){if(!e||!t)throw new Error("TileProvider name and URL are required");Ut.TILE_PROVIDER_URLS[e]=Vt.resolveURL(t);},t.fb=function(e){"string"!=typeof e||e.length>64||!Li.test(e)?mt(`Invalid SDK info "${e}"; expected a "Name/version" string. Ignoring.`):Oi=e;},t.fc=Us,t.fd=function(e,t,i=!1){if(Ls===Fs.deferred||Ls===Fs.loading||Ls===Fs.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Bs=Vt.resolveURL(e),Ls=Fs.deferred,Os=t,Vs(),i||Gs();},t.fe=function(e){Ut.BUILDING_GEN_URL=Vt.resolveURL(e);},t.ff=Ht,t.fg=function(e){const t=Vt.resolveURL(e);Ut.MESHOPT_URL=t,Ut.MESHOPT_SIMD_URL=t;},t.fh=jt,t.fi=function(e){Ut.DRACO_URL=Vt.resolveURL(e);},t.fj=Gt,t.fk=function(e){const t=Kt();if(!t)return;const i=t.delete(Wt);e&&i.then(()=>e()).catch(e);},t.fl=function(e){Ut.MAX_PARALLEL_IMAGE_REQUESTS=e;},t.fm=function(e){Ut.API_URL=e;},t.fn=function(e){Ut.ACCESS_TOKEN=e;},t.fo="hd_road_elevation",t.fp=class{static parseFrom(e,t){const i=sm.parse(e);if(!i)return [];let{vertices:n,features:r}=i;const o=1/Au(t);r.sort((e,t)=>e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,i)=>t===i.findIndex(t=>t.id===e.id&&t.idx===e.idx));const a=new Array;let s=0;const l=n.length;for(const e of r){if(e.constantHeight){a.push(new pm(e.id,e.bounds,e.constantHeight));continue}for(;s!==l&&n[s].id<e.id;)s++;if(s===l||n[s].id!==e.id)continue;const t=new Array,i=new Array,r=s;for(;s!==l&&n[s].id===e.id;){const e=n[s];if(t.push({position:e.position,height:e.height,extent:e.extent,index:e.idx}),s!==r&&n[s-1].idx===e.idx-1){const e=s-r;i.push({a:e-1,b:e});}s++;}a.push(new pm(e.id,e.bounds,void 0,t,i,o));}return a}},t.fq=em,t.fr=tv,t.fs=lg,t.ft=je,t.fu=Kr,t.fv=function(e,t){const i=e.layers[0].layout.get("fill-elevation-reference"),n="hd-road-base"===i||"hd-road-markup"===i?i:null,r=!!t&&t.length>0&&ug(t,e.layers[0].source,e.sourceLayerName);(n||r)&&(e.hdExt=new cg(e,n,r));},t.fw=function(e,t){const i="hd-road-markup"===e.layers[0].layout.get("line-elevation-reference"),n=!!t&&t.length>0&&ug(t,e.layers[0].source,e.sourceLayerName);(i||n)&&(e.hdExt=new fg(i,n));},t.fx=wd,t.fy=function(e){const t=e.layers[0];"circle"===t.type&&"hd-road-markup"===t.layout.get("circle-elevation-reference")&&(e.hdExt=new pg);},t.fz=function(e){"hd-road-markup"===e.layers[0].layout.get("symbol-elevation-reference")&&(e.hdExt=new mg);},t.g=pi,t.g0=D_,t.g1=_f,t.g2=function(e,t){const i=e.stretchY||[[0,e.paddedRect.h-2]];return e.stretchX||e.stretchY?O_(e.stretchX||[[0,e.paddedRect.w-2]])*O_(i):1},t.g3=V_,t.g4=ld,t.g5=2,t.g6=Ob,t.g7=hd,t.g8=ug,t.g9=function(e,t){const i=lg(e);return null!==i&&!!(t&1<<i)},t.ga=ht,t.gb=y_,t.gc=h_,t.gd=x_,t.ge=v_,t.gf=Oh,t.gg=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},t.gh=IA,t.gi=Ph,t.gj=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length;}writeTag(e,t){this.writeVarint(e<<3|t);}realloc(e){let t=this.length||16;for(;t<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*Hp),!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*Hp),!0),this.pos+=8;}writeVarint(e){if((e=+e||0)>=0&&e<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=e);e>268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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)))));}(n,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 n,r,o=0;o<t.length;o++){if(n=t.charCodeAt(o),n>55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null;}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128);}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&qp(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),this.buf.set(e,this.pos),this.pos+=t;}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const n=this.pos-i;n>=128&&qp(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n;}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i);}writePackedVarint(e,t){t.length&&this.writeMessage(e,Xp,t);}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Yp,t);}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Qp,t);}writePackedFloat(e,t){t.length&&this.writeMessage(e,Jp,t);}writePackedDouble(e,t){t.length&&this.writeMessage(e,Kp,t);}writePackedFixed32(e,t){t.length&&this.writeMessage(e,e_,t);}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,t_,t);}writePackedFixed64(e,t){t.length&&this.writeMessage(e,i_,t);}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,n_,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);}},t.gk=vt,t.gl=zp,t.gm=Fs,t.gn=aA,t.go=function(e){Qt(),null!=Jt&&Jt.then(t=>{t.keys().then(i=>{for(let n=0;n<i.length-e;n++)t.delete(i[n]).catch(e=>mt(e.message));}).catch(e=>mt(e.message));}).catch(e=>mt(e.message));},t.h=nn,t.i=Un,t.j=2,t.k=m_,t.l=er,t.m=vl,t.n=Qn,t.o=Nt,t.p=a_,t.q=ir,t.r=za,t.s=nl,t.t=Ta,t.u=rl,t.v=Sa,t.w=mt,t.x=Va,t.y=ol,t.z=ja;});
define(["require","./shared"],function(e,t){function o(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e,o){if(Object.hasOwn(e.layers,t.fo))return t.fp.parseFrom(e.layers[t.fo],o)}function n({buckets:e,data:o,sourceLayerCoder:i,canonical:n,options:s}){if(!s.elevationFeatures||0===s.elevationFeatures.length)return;const r=[];for(const o of Object.values(e))if(o instanceof t.bA&&o.hdExt){const e=o.hdExt.getUnevaluatedPortalGraph();e&&r.push(e);}const a=t.fq.evaluate(r);for(const r of Object.values(e))if(r instanceof t.bA&&r.hdExt){const e=o.layers[i.decode(r.sourceLayerIndex)];r.hdExt.setEvaluatedPortalGraph(a,e,n,s.availableImages,s.brightness,r.worldview);}}function s(e){const o=[];for(let i=0;i<e.length;i++){const n=e.feature(i),s=n.properties.frc_mask;if(null==s)continue;const r=Number(s);if(!r)continue;const a=n.loadGeometry();if(a.length>0){let e=!1;for(const o of a[0])if(o.x<0||o.x>t.a2||o.y<0||o.y>t.a2){e=!0;break}if(e)continue}const l=1===a.length&&5===a[0].length&&a[0].some(e=>e.x<=0&&e.y<=0)&&a[0].some(e=>e.x>=t.a2&&e.y<=0)&&a[0].some(e=>e.x>=t.a2&&e.y>=t.a2)&&a[0].some(e=>e.x<=0&&e.y>=t.a2);o.push(new t.fr(r,l?[]:a));}return o}function r(e,o,i,n,s){const r=t.fs(o);if(null===r)return !1;let a=i.x,l=i.y;const c=s??n.z;if(n.z!==c){const e=1<<n.z-c,o=t.a2/e;a=n.x%e*o+i.x/e,l=n.y%e*o+i.y/e;}for(const o of e){if(!(o.hasGeometry()&&o.frcMask&1<<r))continue;const e=o.rings.map(e=>e.map(e=>[e.x,e.y]));if(t.ft([a,l],e))return !0}return !1}function a(e,o,i,n){const s=o.indoorState.activeFloorsVisible;if(!o.sourceLayers)return s?o.indoorState.activeFloors:void 0;const r=function(e,o){if(!e)return t.w("No source layers defined in indoor specification"),o;if(0===e.size)return o;const i=e.difference(o);for(const e of i)t.w(`Missing source layer required in indoor specification: ${e}`);return o.intersection(o)}(o.sourceLayers,new Set(Object.keys(e.layers))),a=o.indoorState,d=function(e,o,i,n,s){const r={};for(const i of o){const o=e.layers[i];if(o)for(let e=0;e<o.length;e++){const t=o.feature(e);if(f(t)){const{id:e,center:o}=u(t);l(r,e,o);continue}if(g(t)){const e=h(t,s);c(r,e.buildings,e.id,e);}}else t.w(`indoor source layer not found: ${i}`);}return {buildings:r,activeFloors:t.aW.calculate(r,n,i)}}(e,r,a.activeFloors,a.selectedFloorId,n);return i.notify("setIndoorData",d),s?d.activeFloors:void 0}function l(e,t,o){e[t]?o&&(e[t].center=o):e[t]={floorIds:new Set,center:o||[0,0],floors:{}};}function c(e,t,o,i){for(const n of t)l(e,n),e[n].floors[o]=i,e[n].floorIds.add(o);}function u(e){return {id:e.properties.id.toString(),center:[e.properties.center_lon||0,e.properties.center_lat||0]}}function h(e,o){const i=e.properties.id.toString(),n=!!e.properties.is_default&&e.properties.is_default,s=e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,r=e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,a=e.properties.structure_ids?new Set(e.properties.structure_ids.toString().split(";")):new Set,l=e.properties.name.toString(),c=e.properties.z_index,u=function(e,o){const i=e.loadGeometry();if(!i||0===i.length)return;const n=i.map(i=>i.map(i=>t.fu(i,o,e.extent)));return 0===n.length?void 0:{type:"Polygon",coordinates:[n[0]]}}(e,o);return {id:i,isDefault:n,connections:s,conflicts:r,buildings:a,name:l,zIndex:c,geometry:u}}function d(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function f(e){return d(e,["type","id","name"])&&"structure"===e.properties.type}function g(e){return d(e,["type","id","name","z_index"])&&"floor"===e.properties.type}function p(e,o){e instanceof t.bA?t.fv(e,o):e instanceof t.bz?t.fw(e,o):e instanceof t.fx?t.fy(e):e instanceof t.bu&&t.fz(e);}function m(e){for(const o in e){const i=e[o];if(i instanceof t.bz&&i.hdExt&&i.hdExt.hasDeferredElevationFeatures)return !0;if(i instanceof t.bu&&i.hdExt&&i.hdExt.hasDeferredElevationFeatures)return !0}return !1}class y{constructor(e,o,i){this.tileID=new t.bP(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=e.projection,this.brightness=o,this.worldview=i;}async parse(e,o,i){this.status="parsing";const n=new t.bP(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),s=[],r=o.familiesBySource[i.source],a=new t.fA(n,i.promoteId);a.bucketLayerIDs=[],a.is3DTile=!0;const l=await t.fB(e),c=l.json.extensionsUsed&&l.json.extensionsUsed.includes("MAPBOX_mesh_features")||l.json.asset.extras&&l.json.asset.extras.MAPBOX_mesh_features,u=l.json.extensionsUsed&&l.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new t.ai(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const e in r)for(const o of r[e]){const e=o[0];a.bucketLayerIDs.push(o.map(e=>t.m(e.id,e.scope))),e.recalculate(h,[]);const r=t.fC(l,1/t.fD(i.tileID.canonical)),d=new t.fE(o,r,n,c,u,this.brightness,a,this.worldview);c||(d.needsUpload=!0),s.push(d),d.evaluate(e);}return this.status="done",{buckets:s,featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null}}}class x{constructor({actor:e,layerIndex:t,availableImages:o,availableModels:i,brightness:n,worldview:s}){this.actor=e,this.layerIndex=t,this.availableImages=o,this.availableModels=i,this.brightness=n,this.loading={},this.loaded={},this.worldview=s;}async loadTile(e){const o=e.uid,i=new AbortController,n=this.loading[o]=new y(e,this.brightness,this.worldview);n.abort=()=>i.abort();const s=(e,t)=>{const o=n.reloadCallback;o&&(delete n.reloadCallback,o(e,t));};let r;try{r=(await t.cC(e.request,i.signal)).data;}catch(e){if(delete this.loading[o],n.status="done",this.loaded[o]=n,i.signal.aborted)return null;throw e}if(delete this.loading[o],!r||0===r.byteLength)return n.status="done",this.loaded[o]=n,null;try{const t=await n.parse(r,this.layerIndex,e);return this.loaded[o]=n,s(null,t),t}catch(e){throw this.loaded[o]=n,s(e),e}}async reloadTile(e){const t=this.loaded&&this.loaded[e.uid];if(t)return t.projection=e.projection,t.brightness=e.brightness,"parsing"===t.status&&await new Promise((e,o)=>{t.reloadCallback=t=>{t?o(t):e();};}),this.loadTile(e)}abortTile(e){const t=e.uid,o=this.loading[t];o&&(o.abort&&o.abort(),delete this.loading[t]);}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}function v(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const o of e)t+=`${v(o)},`;return `${t}]`}let t="{";for(const o of Object.keys(e).sort())t+=`${o}:${v(e[o])},`;return `${t}}`}function w(e){let o="";for(const i of t.cD)o+=`/${v(e[i])}`;return o}function b(e,t){return function e(o){return "string"==typeof o&&o===t||(Array.isArray(o)?o.some(e):!(!o||"object"!=typeof o)&&Object.values(o).some(e))}(e)}class S{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e);}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t);}update(e,o,i){this._options=i;for(const o of e)this._layerConfigs[o.id]=o,(this._layers[o.id]=t.dj(o,this.scope,null,this._options)).compileFilter(i),this.keyCache[o.id]&&delete this.keyCache[o.id];for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const n=function(e,t){const o=Object.create(null);for(let i=0;i<e.length;i++){const n=e[i];let s=t&&t[n.id];s||("symbol"===n.type?s=n.id:(s=w(n),"line"===n.type&&n.paint&&(b(n.paint["line-width"],"line-progress")&&(s+=`/${v(n.paint["line-width"])}`),b(n.paint["line-emissive-strength"],"line-progress")&&(s+=`/${v(n.paint["line-emissive-strength"])}`)))),t&&(t[n.id]=s);let r=o[s];r||(r=o[s]=[]),r.push(n);}const i=[];for(const e in o)i.push(o[e]);return i}(Object.values(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map(e=>this._layers[e.id]),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let n=this.familiesBySource[i];n||(n=this.familiesBySource[i]=Object.create(null));const s=o.sourceLayer||"_geojsonTileLayer";let r=n[s];r||(r=n[s]=[]),r.push(t);}}}class I extends t.P{constructor(e,t,o,i,n){super(e,t),this.angle=i,this.z=o,void 0!==n&&(this.segment=n);}clone(){return new I(this.x,this.y,this.z,this.angle,this.segment)}}function P(e,t,o,i,n){if(void 0===t.segment)return !0;let s=t,r=t.segment+1,a=0;for(;a>-o/2;){if(r--,r<0)return !1;a-=e[r].dist(s),s=e[r];}a+=e[r].dist(e[r+1]),r++;const l=[];let c=0;for(;a<o/2;){const t=e[r],o=e[r+1];if(!o)return !1;let s=e[r-1].angleTo(t)-t.angleTo(o);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),c+=s;a-l[0].distance>i;)c-=l.shift().angleDelta;if(c>n)return !1;r++,a+=t.dist(o);}return !0}function M(e){let t=0;for(let o=0;o<e.length-1;o++)t+=e[o].dist(e[o+1]);return t}function T(e,t,o){return e?.6*t*o:0}function z(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function B(e,o,i,n,s,r){const a=T(i,s,r),l=z(i,n)*r;let c=0;const u=M(e)/2;for(let i=0;i<e.length-1;i++){const n=e[i],s=e[i+1],r=n.dist(s);if(c+r>u){const h=(u-c)/r,d=t.al(n.x,s.x,h),f=t.al(n.y,s.y,h),g=new I(d,f,0,s.angleTo(n),i);return !a||P(e,g,l,a,o)?g:void 0}c+=r;}}function k(e,t,o,i,n,s,r,a,l){const c=T(i,s,r),u=z(i,n),h=u*r,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),C(e,d?t/2*a%t:(u/2+2*s)*r*a%t,t,c,o,h,d,!1,l)}function C(e,o,i,n,s,r,a,l,c){const u=r/2,h=M(e);let d=0,f=o-i,g=[];for(let o=0;o<e.length-1;o++){const a=e[o],l=e[o+1],p=a.dist(l),m=l.angleTo(a);for(;f+i<d+p;){f+=i;const y=(f-d)/p,x=t.al(a.x,l.x,y),v=t.al(a.y,l.y,y);if(x>=0&&x<c&&v>=0&&v<c&&f-u>=0&&f+u<=h){const t=new I(x,v,0,m,o);n&&!P(e,t,r,n,s)||g.push(t);}}d+=p;}return l||g.length||a||(g=C(e,d/2,i,n,s,r,a,!0,c)),g}t.fF(I,"Anchor");class L{constructor(){this.scale=1,this.fontStack="",this.image=null;}static forText(e,t){const o=new L;return o.scale=e||1,o.fontStack=t,o}static forImage(e){const t=new L;return t.image=e,t}}class D{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(e,t,o,i=1){const n=new D;for(let s=0;s<e.sections.length;s++){const r=e.sections[s];r.image?n.addImageSection(r,o,i):n.addTextSection(r,t);}return n}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=t.fG(this.text,e);}trim(){let e=0;for(let t=0;t<this.text.length&&A[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let o=this.text.length-1;o>=0&&o>=e&&A[this.text.charCodeAt(o)];o--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const o=new D;return o.text=this.text.substring(e,t),o.sectionIndex=this.sectionIndex.slice(e,t),o.sections=this.sections,o}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(L.forText(e.scale,e.fontStack||t));const o=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(o);}addImageSection(e,o,i=1){const n=e.image?e.image.getPrimary():null;if(!n)return void t.w("Can't add FormattedSection with an empty image.");n.scaleSelf(o*i);const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCodePoint(s),this.sections.push(L.forImage(n)),this.sectionIndex.push(this.sections.length-1)):t.w("Reached maximum number of images 6401");}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function F(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p,m=1,y=1){const x=D.fromFeature(e,s,m,y);d===t.cL.vertical&&x.verticalizePunctuation(f);let v=[];const w=function(e,o,i,n,s,r,a){if(!e)return [];const l=[],c=function(e,t,o,i,n,s,r){let a=0;for(let o=0;o<e.length();o++){const l=e.getSection(o);a+=E(e.getCodePoint(o),l,i,n,t,s,r);}return a/Math.max(1,Math.ceil(a/o))}(e,o,i,n,s,r,a),u=e.text.includes("");let h=0;for(let i=0;i<e.length();i++){const d=e.getSection(i),f=e.getCodePoint(i);if(A[f]||(h+=E(f,d,n,s,o,r,a)),i<e.length()-1){const o=t.fI(f);(_[f]||o||d.image)&&l.push(j(i+1,h,c,l,R(f,e.getCodePoint(i+1),o&&u),!1));}}return V(j(e.length(),h,c,l,0,!0))}(x,u,r,o,n,g,y),{processBidirectionalText:b,processStyledBidirectionalText:S}=t.fH;if(b&&1===x.sections.length){const e=b(x.toString(),w);for(const t of e){const e=new D;e.text=t,e.sections=x.sections;for(let o=0;o<t.length;o++)e.sectionIndex.push(0);v.push(e);}}else if(S){const e=S(x.text,x.sectionIndex,w);for(const t of e){const e=new D;e.text=t[0],e.sectionIndex=t[1],e.sections=x.sections,v.push(e);}}else v=function(e,t){const o=[],i=e.text;let n=0;for(const i of t)o.push(e.substring(n,i)),n=i;return n<i.length&&o.push(e.substring(n,i.length)),o}(x,w);const I=[],P={positionedLines:I,text:x.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:d,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(e,o,i,n,s,r,a,l,c,u,h,d,f){let g=0,p=0,m=0;const y="right"===l?1:"left"===l?0:.5;let x=!1;for(const e of s){const t=e.getSections();for(const e of t){if(e.image)continue;const t=o[e.fontStack];if(t&&(x=void 0!==t.ascender&&void 0!==t.descender,!x))break}if(!x)break}let v=0;for(const a of s){a.trim();const s=a.getMaxScale(),l=(s-1)*t.d1,w={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=w;const b=w.positionedGlyphs;let S=0;if(!a.length()){p+=r,++v;continue}let I=0,P=0;for(let r=0;r<a.length();r++){const l=a.getSection(r),m=a.getSectionIndex(r),y=a.getCodePoint(r);let v=l.scale,w=null,M=null,T=null,z=t.d1,B=0,k=c;k===t.cL.vertical&&t.fL(y)&&(k=t.cL.horizontal);const C=!(k===t.cL.horizontal||!h&&!t.fJ(y)||h&&(A[y]||t.fK(y)));if(l.image){const o=n.get(l.image.toString());if(!o)continue;T=l.image,e.iconsInText=!0,M=o.paddedRect;const i=o.displaySize,r=i[0]*f,a=i[1]*f;v=v*t.d1/d,w={width:r,height:a,left:0,top:-t.fM,advance:C?a:r,localGlyph:!1},B=x?-w.height*v:s*t.d1-17-a*v,z=w.advance;const c=(C?r:a)*v-t.d1*s;c>0&&c>S&&(S=c);}else {const e=i[l.fontStack];if(!e)continue;e[y]&&(M=e[y]);const n=o[l.fontStack];if(!n)continue;const r=n.glyphs[y];if(!r)continue;if(w=r.metrics,z=8203!==y?t.d1:0,x){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,o=(e+t)*v;I<o&&(I=o,P=(e-t)/2*v),B=-e*v;}else B=(s-v)*t.d1-17;}b.push({glyph:y,image:T,x:g,y:p+B,vertical:C,scale:v,localGlyph:w.localGlyph,fontStack:l.fontStack,sectionIndex:m,metrics:w,rect:M}),C?(e.verticalizable=!0,g+=z*v+u):g+=w.advance*v+u;}0!==b.length&&(m=Math.max(g-u,m),x?Z(b,y,S,P,r*s/2):Z(b,y,S,0,r/2)),g=0;const M=r*s+S;w.lineOffset=Math.max(S,l),p+=M,++v;}const w=p,{horizontalAlign:b,verticalAlign:S}=t.cM(a);((function(e,t,o,i,n,s){const r=(t-o)*n,a=-s*i;for(const t of e)for(const e of t.positionedGlyphs)e.x+=r,e.y+=a;}))(e.positionedLines,y,b,S,m,w),e.top+=-S*w,e.bottom=e.top+w,e.left+=-b*m,e.right=e.left+m,e.hasBaseline=x;}(P,o,i,n,v,a,l,c,d,u,f,p,y),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return !1;return !0}(I))return P}const A={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},_={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function E(e,o,i,n,s,r,a){if(o.image){const e=n.get(o.image.toString());return e?e.displaySize[0]*a*o.scale*t.d1/r+s:0}{const t=i[o.fontStack],n=t&&t.glyphs[e];return n?n.metrics.advance*o.scale+s:0}}function O(e,t,o,i){const n=Math.pow(e-t,2);return i?e<t?n/2:2*n:n+Math.abs(o)*o}function R(e,t,o){let i=0;return 10===e&&(i-=1e4),o&&(i+=150),40!==e&&65288!==e||(i+=50),41!==t&&65289!==t||(i+=50),i}function j(e,t,o,i,n,s){let r=null,a=O(t,o,n,s);for(const e of i){const i=O(t-e.x,o,n,s)+e.badness;i<=a&&(r=e,a=i);}return {index:e,x:t,priorBreak:r,badness:a}}function V(e){return e?V(e.priorBreak).concat(e.index):[]}function Z(e,t,o,i,n){if(!(t||o||i||n))return;const s=e.length-1,r=e[s],a=(r.x+r.metrics.advance*r.scale)*t;for(let t=0;t<=s;t++)e[t].x-=a,e[t].y+=o+i+n;}function N(e,o=1,i=!1){let n=1/0,s=1/0,r=-1/0,a=-1/0;const l=e[0];for(let e=0;e<l.length;e++){const t=l[e];(!e||t.x<n)&&(n=t.x),(!e||t.y<s)&&(s=t.y),(!e||t.x>r)&&(r=t.x),(!e||t.y>a)&&(a=t.y);}const c=Math.min(r-n,a-s);let u=c/2;const h=new t.fN([],U);if(0===c)return new t.P(n,s);for(let t=n;t<r;t+=c)for(let o=s;o<a;o+=c)h.push(new G(t+u,o+u,u,e));let d=function(e){let t=0,o=0,i=0;const n=e[0];for(let e=0,s=n.length,r=s-1;e<s;r=e++){const s=n[e],a=n[r],l=s.x*a.y-a.x*s.y;o+=(s.x+a.x)*l,i+=(s.y+a.y)*l,t+=3*l;}return new G(o/t,i/t,0,e)}(e),f=h.length;for(;h.length;){const t=h.pop();(t.d>d.d||!d.d)&&(d=t,i&&console.log("found best %d after %d probes",Math.round(1e4*t.d)/1e4,f)),t.max-d.d<=o||(u=t.h/2,h.push(new G(t.p.x-u,t.p.y-u,u,e)),h.push(new G(t.p.x+u,t.p.y-u,u,e)),h.push(new G(t.p.x-u,t.p.y+u,u,e)),h.push(new G(t.p.x+u,t.p.y+u,u,e)),f+=4);}return i&&(console.log(`num probes: ${f}`),console.log(`best distance: ${d.d}`)),d.p}function U(e,t){return t.max-e.max}class G{constructor(e,o,i,n){this.p=new t.P(e,o),this.h=i,this.d=function(e,o){let i=!1,n=1/0;for(let s=0;s<o.length;s++){const r=o[s];for(let o=0,s=r.length,a=s-1;o<s;a=o++){const s=r[o],l=r[a];s.y>e.y!=l.y>e.y&&e.x<(l.x-s.x)*(e.y-s.y)/(l.y-s.y)+s.x&&(i=!i),n=Math.min(n,t.fO(e,s,l));}}return (i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const H=Object.keys;function Y(e){return void 0!==e.imagePrimary&&void 0!==e.top&&void 0!==e.bottom&&void 0!==e.left&&void 0!==e.right}function X(e){return !e.imagePrimary.stretchX}function $(e){return !e.imagePrimary.stretchY}function q(e){return {width:e.right-e.left,height:e.bottom-e.top}}const J=Number.POSITIVE_INFINITY;function W(e,o,i,n,s,r){const a=Y(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],l={top:e.top-a[1],bottom:e.bottom+a[3],left:e.left-a[0],right:e.right+a[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0;}(l,n),r&&(l.left+=r[0],l.right+=r[0],l.top+=r[1],l.bottom+=r[1]),i&&function(e,o,i){if(!o)return;const n=t.au(o),s=new t.P(i?i[0]:0,i?i[1]:0),r=new t.P(e.left,e.top),a=new t.P(e.right,e.top),l=new t.P(e.left,e.bottom),c=new t.P(e.right,e.bottom);r._rotateAround(n,s),a._rotateAround(n,s),l._rotateAround(n,s),c._rotateAround(n,s),e.left=Math.min(r.x,a.x,l.x,c.x),e.right=Math.max(r.x,a.x,l.x,c.x),e.top=Math.min(r.y,a.y,l.y,c.y),e.bottom=Math.max(r.y,a.y,l.y,c.y);}(l,i,s),o?{top:Math.min(o.top,l.top),bottom:Math.max(o.bottom,l.bottom),left:Math.min(o.left,l.left),right:Math.max(o.right,l.right),scaled:o.scaled||l.scaled}:l}function Q(e,o,i,n,s,r,a,l=1,c,u,h,d,f,g,p,m,y){e.createArrays(),e.tilePixelRatio=t.a2/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const x=e.layers[0].layout,v=e.layers[0]._unevaluatedLayout._values,w={};w.scaleFactor=l,w.textSizeScaleRange=x.get("text-size-scale-range"),w.iconSizeScaleRange=x.get("icon-size-scale-range");const[b,S]=w.textSizeScaleRange,[I,P]=w.iconSizeScaleRange;w.textScaleFactor=t.b0(w.scaleFactor,b,S),w.iconScaleFactor=t.b0(w.scaleFactor,I,P);const M=v["text-size"],T=v["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:o,maxZoom:i}=e.textSizeData;w.compositeTextSizes=[M.possiblyEvaluate(new t.ai(o,{worldview:h}),r),M.possiblyEvaluate(new t.ai(i,{worldview:h}),r)];}if("composite"===e.iconSizeData.kind){const{minZoom:o,maxZoom:i}=e.iconSizeData;w.compositeIconSizes=[T.possiblyEvaluate(new t.ai(o,{worldview:h}),r,d),T.possiblyEvaluate(new t.ai(i,{worldview:h}),r,d)];}w.layoutTextSize=M.possiblyEvaluate(new t.ai(a+1,{worldview:h}),r),w.layoutIconSize=T.possiblyEvaluate(new t.ai(a+1,{worldview:h}),r,d),w.textMaxSize=M.possiblyEvaluate(new t.ai(18,{worldview:h}),r);const z=x.get("symbol-placement"),B="map"===x.get("text-rotation-alignment")&&"point"!==z,k=x.get("text-size");let C=!1;const L=[],D=null!=f&&0!==f;for(const a of e.features){if(D&&a.properties&&m&&m(a.properties,f))continue;let l=65535;if(e.hdExt&&a.properties&&Object.hasOwn(a.properties,t.fP)){const o=+a.properties[t.fP];if(!Number.isNaN(o)){const t=e.hdExt.resolveRoadElevation(a,o);if("defer"===t)continue;l=t;}}const g=x.get("text-font").evaluate(a,{},r).join(","),p=k.evaluate(a,{},r)*w.textScaleFactor,y=w.layoutTextSize.evaluate(a,{},r)*w.textScaleFactor,b=w.layoutIconSize.evaluate(a,{},r,d)*w.iconScaleFactor,S={horizontal:{},vertical:void 0},I=a.text;let P,M=[0,0];if(I){const n=I.toString(),l=x.get("text-letter-spacing").evaluate(a,{},r)*t.d1,u=x.get("text-line-height").evaluate(a,{},r)*t.d1,h=t.fQ(n)?l:0,d=x.get("text-anchor").evaluate(a,{},r),f=x.get("text-variable-anchor");if(!f){const e=x.get("text-radial-offset").evaluate(a,{},r);if(e)M=t.cN(d,[e*t.d1,J]);else {const e=x.get("text-offset").evaluate(a,{},r);M=[e[0]*t.d1,e[1]*t.d1];}}let m=B?"center":x.get("text-justify").evaluate(a,{},r);const v="point"===z,b=v?x.get("text-max-width").evaluate(a,{},r)*t.d1:1/0,P=r=>{e.allowVerticalPlacement&&t.fR(n)&&(S.vertical=F(I,o,i,s,g,b,u,d,r,h,M,t.cL.vertical,!0,y,p,c,w.textScaleFactor));};if(!B&&f){const e="auto"===m?f.map(e=>t.cO(e)):[m];let n=!1;for(let r=0;r<e.length;r++){const a=e[r];if(!S.horizontal[a])if(n)S.horizontal[a]=S.horizontal[0];else {const e=F(I,o,i,s,g,b,u,"center",a,h,M,t.cL.horizontal,!1,y,p,c,w.textScaleFactor);e&&(S.horizontal[a]=e,n=1===e.positionedLines.length);}}P("left");}else {if("auto"===m&&(m=t.cO(d)),v||x.get("text-writing-mode").includes("horizontal")||!t.fR(n)){const e=F(I,o,i,s,g,b,u,d,m,h,M,t.cL.horizontal,!1,y,p,c,w.textScaleFactor);e&&(S.horizontal[m]=e);}P(v?"left":m);}}let T,A,_,E,O,R,j=!1;const V=x.get("icon-text-fit").evaluate(a,{},r);if(a.icon&&a.icon.hasPrimary()){const o=t.fS(a.icon,e.iconSizeData,v["icon-size"],r,e.zoom,a,c,w.iconScaleFactor,h,d);T=o.iconPrimary,_=o.iconSecondary;const i=T.toString();if(A=n.get(i),A&&(O=x.get("icon-offset").evaluate(a,{},r),R=x.get("icon-anchor").evaluate(a,{},r),P=t.fT(s.get(i),_?s.get(_.toString()):void 0,O,R),j=A.sdf,void 0===e.sdfIcons?e.sdfIcons=A.sdf:e.sdfIcons!==A.sdf&&t.w("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(A.pixelRatio!==e.pixelRatio||0!==x.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),_){const e=_.toString();E=n.get(e);}}C=C||!(!a.icon||!a.icon.hasSecondary());const Z=de(S.horizontal)||S.vertical;e.iconsInText||(e.iconsInText=!!Z&&Z.iconsInText);const N=t.fU(y,w.textScaleFactor),{defaultShapedIcon:U,verticallyShapedIcon:G}=ce(e,P,x,a,r,S,N,O,V);"none"!==V&&P&&(X(P)||$(P))&&(ie(A,T,P,U,V,u,n,s),ie(E,_,P,U,V,u,n,s),G&&(ie(A,T,P,G,V,u,n,s),ie(E,_,P,G,V,u,n,s))),P=U;const{iconBBox:H,iconVerticalBBox:Y,textBBox:q,textVerticalBBox:W}=K(e,P,G,x,a,r,b,O,w,s,R,S,y,M,d);L.push({feature:a,shapedTextOrientations:S,shapedText:Z,shapedIcon:P,iconPrimary:T,iconSecondary:_,iconOffset:O,iconAnchor:R,verticallyShapedIcon:G,layoutTextSize:y,layoutIconSize:b,textOffset:M,isSDFIcon:j,iconTextFit:V,iconCollisionBounds:H,iconVerticalCollisionBounds:Y,textCollisionBounds:q,textVerticalCollisionBounds:W,elevationFeatureIndex:l});}return e.hdExt&&e.hdExt.clearWorkerState(),{featureData:L,sizes:w,hasAnySecondaryIcon:C,textAlongLine:B,symbolPlacement:z,coverageFrcMask:f,coveragePolygons:g,coverageTileZoom:p,isFeatureCoveredByFrcMask:m,symbolAnchorInFrcCoverage:y}}function K(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p){const m=e.layers[0],y=m.appearances;if(0===y.length)return {iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const x={iconBBox:null,iconVerticalBBox:null},v={textBBox:null,textVerticalBBox:null},{baseIconRotate:w,baseTextRotate:b,iconScaleFactor:S}=function(e,o,i){const n=e.get("icon-rotate").evaluate(o,{},i),s=e.get("text-rotate").evaluate(o,{},i),[r,a]=e.get("icon-size-scale-range");return {baseIconRotate:n,baseTextRotate:s,iconScaleFactor:t.b0(1,r,a)}}(n,s,r);o&&(x.iconBBox=W(o,x.iconBBox,w),i)&&(x.iconVerticalBBox=W(i,x.iconVerticalBBox,w+90));const I=de(d.horizontal);I&&(v.textBBox=W(I,v.textBBox,b,1,g)),d.vertical&&(v.textVerticalBBox=W(d.vertical,v.textVerticalBBox,b+90,1,g));for(const t of y)t.hasIconLayoutProperties()&&ee(x,e,m,t,s,r,l,w,a,c,o,u,S,h,p),t.hasTextLayoutProperties()&&oe(v,m,t,s,r,g,b,f,I,d.vertical);return {iconBBox:x.iconBBox,iconVerticalBBox:x.iconVerticalBBox,textBBox:v.textBBox,textVerticalBBox:v.textVerticalBBox}}function ee(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p){const{appearanceIconOffset:m,appearanceIconRotate:y,appearanceIconSize:x}=t.fY(n,i,s,r,a,l,c,u.iconScaleFactor);let v=null,w=null,b=null;n.hasLayoutProperty("icon-image")?b=te(o,i,n,s,r,d,f,p):h&&(b=h.imagePrimary),b&&(v=t.fT(b,null,m,g),o.allowVerticalPlacement&&(w=v));const S=c>0?x/c:1;v&&(e.iconBBox=W(v,e.iconBBox,y,1!==S?S:void 0)),w&&(e.iconVerticalBBox=W(w,e.iconVerticalBBox,y+90,1!==S?S:void 0));}function te(e,o,i,n,s,r,a,l){let c=null;const u=o.getAppearanceValueAndResolveTokens(i,"icon-image",n,s,l);if(u){const h=e.getResolvedImageFromTokens(u),d=i.hasLayoutProperty("icon-size")?i.getUnevaluatedLayoutProperty("icon-size"):o._unevaluatedLayout._values["icon-size"],f=t.f$(e.zoom,d,e.worldview,l),g=t.fS(h,f,d,s,e.zoom,n,e.pixelRatio,a,e.worldview,l);c=r.get(g.iconPrimary.toString());}return c}function oe(e,o,i,n,s,r,a,l,c,u){const{appearanceTextOffset:h,appearanceTextRotate:d,appearanceTextSize:f}=t.fZ(i,o,n,s,r,a,l),g=f/l,p=[(h[0]-r[0])*g,(h[1]-r[1])*g],m=0!==p[0]||0!==p[1];c&&(e.textBBox=W(c,e.textBBox,d,g,h,m?p:void 0)),u&&(e.textVerticalBBox=W(u,e.textVerticalBBox,d+90,g,h,m?p:void 0));}function ie(e,o,i,n,s,r,a,l){if(!e||!e.usvg)return;const c=q(i),u=q(n),h="both"!==s&&"width"!==s||!X(i)?1:u.width/c.width,d="both"!==s&&"height"!==s||!$(i)?1:u.height/c.height;o.scaleSelf(h,d);const f=o.toString();r.set(f,o),a.set(f,e);const{imagePosition:g}=t.fW(f,e,t.fX);l.set(f,g);}function ne(e,o,i){if(!o)return;const n=i.get(e.toString()),s=i.get(o.toString());n&&s&&(n.paddedRect.w===s.paddedRect.w&&n.paddedRect.h===s.paddedRect.h||t.w(`Mismatch in icon variant sizes: ${e.toString()} and ${o.toString()}`),n.usvg!==s.usvg&&t.w(`Mismatch in icon variant image types: ${e.id} and ${o.id}`));}function se(e,t,o,i,n,s,r,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,sizes:h,textAlongLine:d,symbolPlacement:f,coveragePolygons:g,coverageTileZoom:p,symbolAnchorInFrcCoverage:m}=t,y=t.hasAnySecondaryIcon||e.hasAnySecondaryIcon;for(const t of u){const{shapedIcon:o,verticallyShapedIcon:s,feature:u,shapedTextOrientations:x,shapedText:v,layoutTextSize:w,textOffset:b,isSDFIcon:S,iconPrimary:I,iconSecondary:P,iconTextFit:M,iconOffset:T,iconCollisionBounds:z,iconVerticalCollisionBounds:B,textCollisionBounds:k,elevationFeatureIndex:C}=t;re(o,c.iconPositions,I,P),re(s,c.iconPositions,I,P),ae(x,c.iconPositions),ne(I,P,c.iconPositions),(v||o)&&ue(e,u,x,o,s,l,h,w,0,b,S,i,n,r,a,y,M,T,d,f,z,B,k,0,0,g,p,m,C);}o&&e.generateCollisionDebugBuffers(s,e.collisionBoxArray,h.textScaleFactor),e.text.uboBinder&&e.text.uboBinder.finalize(),e.icon.uboBinder&&e.icon.uboBinder.finalize();}function re(e,t,o,i){if(!e)return;const n=t.get(o.toString());if(n&&(e.imagePrimary=n),i){const o=t.get(i.toString());e.imageSecondary=o;}}function ae(e,t){for(const o in e.horizontal)le(e.horizontal[o],t);le(e.vertical,t);}function le(e,t){if(e)for(const o of e.positionedLines)for(const e of o.positionedGlyphs)if(null!==e.image){const o=e.image.toString();e.rect=t.get(o).paddedRect;}}function ce(e,o,i,n,s,r,a,l,c){const u=de(r.horizontal)||r.vertical,h=i.get("icon-text-fit-padding").evaluate(n,{},s);let d,f=o;return o&&"none"!==c&&(e.allowVerticalPlacement&&r.vertical&&(d=t.fV(o,r.vertical,c,h,l,a)),u&&(f=t.fV(o,u,c,h,l,a))),{defaultShapedIcon:f,verticallyShapedIcon:d}}function ue(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p,m,y,x,v,w,b,S,P,M,T,z,C,L,D=65535){let F=a.textMaxSize.evaluate(o,{},f);void 0===F?F=l*a.textScaleFactor:F*=a.textScaleFactor;const A=e.layers[0].layout,_=t.d1,E=t.fU(l,a.textScaleFactor),O=de(i.horizontal)||i.vertical,R=e.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),j=e.getAppearanceFeatureData(o.index);("none"!==y||R)&&j&&(j.textShaping=O,j.iconTextFitPadding=A.get("icon-text-fit-padding").evaluate(o,{},f),j.fontScale=E,j.textScaleFactor=a.textScaleFactor);const V="globe"===g.name,Z=e.tilePixelRatio*F/_,U=(W=e.overscaling,e.zoom>18&&W>2&&(W>>=1),Math.max(t.a2/(512*W),1)*A.get("symbol-spacing")),G=A.get("text-padding")*e.tilePixelRatio,Y=A.get("icon-padding")*e.tilePixelRatio,X=t.au(A.get("text-max-angle")),$="map"===A.get("icon-rotation-alignment")&&"point"!==w,q=U/2;var W;!1===e.hasAnyIconTextFit&&"none"!==y&&(e.hasAnyIconTextFit=!0);const Q=(l,c,w)=>{if(c.x<0||c.x>=t.a2||c.y<0||c.y>=t.a2)return;if(z&&z.length>0&&o.properties&&L&&L(z,o.properties,c,f,C))return;let M=null;if(V){const{x:e,y:t,z:o}=g.projectTilePoint(c.x,c.y,w);M={anchor:new I(e,t,o,0,void 0),up:g.upVector(w,c.x,c.y)};}!function(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p,m,y,x,v,w,b,S,I,P,M,T,z,B,k,C,L,D){const F=e.addToLineVertexArray(o,n);let A,_,E,O,R,j,V,Z=0,N=0,U=0,G=0,Y=-1,X=-1;const $={};let q=t.dc("");const W=i?i.anchor:o,Q="none"!==B;let K=0,ee=0;if(void 0===c._unevaluatedLayout.getValue("text-radial-offset")){const e=c.layout.get("text-offset").evaluate(b,{},M);K=e[0]*t.d1,ee=e[1]*t.d1;}else K=c.layout.get("text-radial-offset").evaluate(b,{},M)*t.d1,ee=J;if(e.allowVerticalPlacement&&s.vertical){const e=s.vertical;if(p)j=ge(e),l&&(V=ge(l));else {const t=c.layout.get("text-rotate").evaluate(b,{},M)+90;E=fe(u,W,o,h,d,f,e,g,t,m,D),l&&(O=fe(u,W,o,h,d,f,l,x,t,null,L));}}if(r){const n=c.layout.get("icon-rotate").evaluate(b,{},M),s=t.g0(r,n,I,Q,S.iconScaleFactor),a=l?t.g0(l,n,I,Q,S.iconScaleFactor):void 0;_=fe(u,W,o,h,d,f,r,x,n,null,C);const g=function(e,o,i,n,s,r,a,l,c){const u=e.layers[0],h=u.appearances;let d=o.length;if(i&&(d=Math.max(d,i.length)),0===h.length)return d;const[f,g]=n.get("icon-size-scale-range"),p=t.b0(1,f,g);for(const o of h)if(o.hasLayoutProperty("icon-image")){const i=te(e,u,o,s,r,a,p,c);i&&(d=Math.max(d,t.g2(i)));}return d}(e,s,a,c.layout,b,M,e.iconAtlasPositions,0,P);Z=4*g;const p=c.layout.get("icon-size").evaluate(b,{},M,P),m=S.compositeIconSizes?S.compositeIconSizes[0].evaluate(b,{},M,P):0,y=S.compositeIconSizes?S.compositeIconSizes[1].evaluate(b,{},M,P):0,B=t.g1(e.layerIds[0],e.iconSizeData,p,r.imagePrimary.usvg?1:S.iconScaleFactor,m,y);e.addSymbols(e.icon,s,B,w,v,b,void 0,i,o,F.lineStartIndex,F.lineLength,-1,P,M,T,z,e.symbolInstances.length,g),Y=e.icon.placedSymbolArray.length-1,a&&(N=4*g,e.addSymbols(e.icon,a,B,w,v,b,t.cL.vertical,i,o,F.lineStartIndex,F.lineLength,-1,P,M,T,z,e.symbolInstances.length,g),X=e.icon.placedSymbolArray.length-1);}for(const n in s.horizontal){const r=n,l=s.horizontal[r];A||(q=t.dc(l.text),p?R=ge(l):A=fe(u,W,o,h,d,f,l,g,c.layout.get("text-rotate").evaluate(b,{},M),m,D));const y=1===l.positionedLines.length;if(U+=he(e,i,o,l,a,c,p,b,m,F,s.vertical?t.cL.horizontal:t.cL.horizontalOnly,y?H(s.horizontal):[r],$,Y,S,P,M,e.symbolInstances.length,T),y)break}s.vertical&&(G+=he(e,i,o,s.vertical,a,c,p,b,m,F,t.cL.vertical,["vertical"],$,X,S,P,M,e.symbolInstances.length,T));let oe=-1;const ie=(e,t)=>e?Math.max(e,t):t;oe=ie(R,oe),oe=ie(j,oe),oe=ie(V,oe);const ne=oe>-1?1:0;e.glyphOffsetArray.length>=65535&&t.w("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(o.x,o.y,W.x,W.y,W.z,$.right>=0?$.right:-1,$.center>=0?$.center:-1,$.left>=0?$.left:-1,$.vertical>=0?$.vertical:-1,Y,X,q,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,void 0!==E?E:e.collisionBoxArray.length,void 0!==E?E+1:e.collisionBoxArray.length,void 0!==_?_:e.collisionBoxArray.length,void 0!==_?_+1:e.collisionBoxArray.length,O||e.collisionBoxArray.length,O?O+1:e.collisionBoxArray.length,h,U,G,Z,N,ne,0,K,ee,oe,0,Q?1:0,k);}(e,c,M,l,i,n,r,s,e.layers[0],e.collisionBoxArray,o.index,o.sourceLayerIndex,e.index,G,v,u,0,Y,$,x,o,a,h,d,f,p,m,y,D,b,S,P);};if("line"===w)for(const s of t.cZ(o.geometry,0,0,t.a2,t.a2)){const o=k(s,U,X,i.vertical||O,n,_,Z,e.overscaling,t.a2);for(const t of o)O&&pe(e,O.text,q,t)||Q(s,t,f);}else if("line-center"===w){for(const e of o.geometry)if(e.length>1){const t=B(e,X,i.vertical||O,n,_,Z);t&&Q(e,t,f);}}else if("Polygon"===o.type)for(const e of t.f_(o.geometry,0)){const t=N(e,16);Q(e[0],new I(t.x,t.y,0,0,void 0),f);}else if("LineString"===o.type)for(const e of o.geometry)Q(e,new I(e[0].x,e[0].y,0,0,void 0),f);else if("Point"===o.type)for(const e of o.geometry)for(const t of e)Q([t],new I(t.x,t.y,0,0,void 0),f);}function he(e,o,i,n,s,r,a,l,c,u,h,d,f,g,p,m,y,x,v){const w=t.g3(i,n,c,r,a,l,s,e.allowVerticalPlacement,void 0,p.textScaleFactor),b=r.layout.get("text-size").evaluate(l,{},y),S=p.compositeTextSizes?p.compositeTextSizes[0].evaluate(l,{},y):0,I=p.compositeTextSizes?p.compositeTextSizes[1].evaluate(l,{},y):0,P=t.g1(e.layerIds[0],e.textSizeData,b,p.textScaleFactor,S,I);e.addSymbols(e.text,w,P,c,a,l,h,o,i,u.lineStartIndex,u.lineLength,g,m,y,v,!1,x,w.length);for(const t of d)f[t]=e.text.placedSymbolArray.length-1;return 4*w.length}function de(e){for(const t in e)return e[t];return null}function fe(e,o,i,n,s,r,a,l,c,u,h){let d,f,g,p;if(d=h?h.top:a.top,f=h?h.bottom:a.bottom,g=h?h.left:a.left,p=h?h.right:a.right,Y(a)&&a.collisionPadding){const e=a.collisionPadding;g-=e[0],d-=e[1],p+=e[2],f+=e[3];}if(c){const e=new t.P(g,d),o=new t.P(p,d),i=new t.P(g,f),n=new t.P(p,f),s=t.au(c);let r=new t.P(0,0);u&&(r=new t.P(u[0],u[1])),e._rotateAround(s,r),o._rotateAround(s,r),i._rotateAround(s,r),n._rotateAround(s,r),g=Math.min(e.x,o.x,i.x,n.x),p=Math.max(e.x,o.x,i.x,n.x),d=Math.min(e.y,o.y,i.y,n.y),f=Math.max(e.y,o.y,i.y,n.y);}return e.emplaceBack(o.x,o.y,o.z,i.x,i.y,g,d,p,f,l,n,s,r),e.length-1}function ge(e){Y(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function pe(e,t,o,i){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(i.dist(e[t])<o)return !0}else n[t]=[];return n[t].push(i),!1}const me=1*t.g5;class ye{constructor(e){const o={},i=[];for(const t in e){const n=e[t],s=o[t]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o=t.metrics.localGlyph?me:1,r={x:0,y:0,w:t.bitmap.width+2*o,h:t.bitmap.height+2*o};i.push(r),s[e]=r;}}const{w:n,h:s}=t.p(i),r=new t.g4({width:n||1,height:s||1});for(const i in e){const n=e[i];for(const e in n.glyphs){const s=n.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][e],l=s.metrics.localGlyph?me:1;t.g4.copy(s.bitmap,r,{x:0,y:0},{x:a.x+l,y:a.y+l},s.bitmap);}}this.image=r,this.positions=o;}}function xe(e){for(const t of e){if(null!=t.hdExt)return !0;if(t.requiresHDRuntime)return !0}return !1}function ve(e){for(const t of e)if(t.requiresStandardRuntime)return !0;return !1}function we(e,o,i){const n=null!=e&&!!t.g8&&t.g8(e.sourceLayers,o,i);return {applies:n,frcMask:n&&e?e.frcMask:null,polygons:n&&e?e.polygons:null,tileZoom:n&&e?e.tileZoom:null}}t.fF(ye,"GlyphAtlas");class be{constructor(e){this.tileID=new t.bP(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.collectResourceTiming=!!e.request&&e.request.collectResourceTiming,this.promoteId=e.promoteId,this.renderSourceType=e.renderSourceType,this.frcCoverage=e.frcCoverage||null,this.elevation=e.elevation||null,this.crossSourceElevationEnabled=!!e.crossSourceElevationEnabled,this.terrainEnabled=!!e.terrainEnabled,this.deferRoadStructure=!1,this.tileTransform=t.bp(e.tileID.canonical,e.projection),this.projection=e.projection,this.worldview=e.worldview,this.localizableLayerIds=e.localizableLayerIds,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep,this.scaleFactor=e.scaleFactor,this.worldview=e.worldview,this.indoor=e.indoor;}isLayerActiveForTile(e){return !(this.renderSourceType===t.bR.Symbol&&"symbol"!==e.type||this.renderSourceType===t.bR.FillExtrusion&&"fill-extrusion"!==e.type||this.renderSourceType===t.bR.Other&&("symbol"===e.type||"fill-extrusion"===e.type)||this.renderSourceType===t.bR.HdRoadElevation||e.minzoom&&this.zoom<Math.floor(e.minzoom)||e.maxzoom&&this.zoom>=e.maxzoom||"none"===e.visibility)}parse(e,t,o,i,n,s){this._parseAfterHD(e,t,o,i,n,s);}_parseAfterHD(e,o,l,c,u,h){let d;if(this.status="parsing",this.data=e,this.renderSourceType===t.bR.HdRoadCoverage){const o=e.layers[t.bU];d=o&&s?s(o):[];}this.collisionBoxArray=new t.bt;const f=new t.g6(Object.keys(e.layers).sort()),g=new t.fA(this.tileID,this.promoteId);g.bucketLayerIDs=[];const y={},x=new t.g7(256,256),v={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:x,availableImages:l,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,elevationParams:this.elevation,crossSourceElevationEnabled:this.crossSourceElevationEnabled,terrainEnabled:this.terrainEnabled,activeFloors:void 0};this.indoor&&a&&(v.activeFloors=a(e,this.indoor,u,this.canonical));const w=[],b=o.familiesBySource[this.source];if(this.renderSourceType===t.bR.HdRoadElevation){const t=i&&i(e,this.canonical)||[],o=new ye({});return this.status="done",void h(null,{buckets:[],containsHdExt:!1,containsStandardExt:!1,featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:o.image,lineAtlas:x,imageAtlas:null,brightness:this.brightness,parsedElevationFeatures:t})}if(this.deferRoadStructure=!1,this.renderSourceType!==t.bR.HdRoadCoverage&&null!=this.frcCoverage&&!this.frcCoverage.resolved&&null===this.frcCoverage.frcMask)for(const e in b)if(t.g8&&t.g8(this.frcCoverage.sourceLayers,this.source,e)){this.deferRoadStructure=!0;break}for(const o in b){const n=e.layers[o];if(!n)continue;let s=!1,r=!1,a=!1,u=!1;for(const e of b[o])"symbol"===e[0].type?s=!0:"fill-extrusion"===e[0].type?r=!0:a=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(this.renderSourceType===t.bR.Symbol&&!s)continue;if(this.renderSourceType===t.bR.FillExtrusion&&!r)continue;if((this.renderSourceType===t.bR.Other||this.renderSourceType===t.bR.HdRoadCoverage)&&!a)continue;const h=null!=this.frcCoverage&&!!t.g8&&t.g8(this.frcCoverage.sourceLayers,this.source,o);if(this.deferRoadStructure&&h)continue;1===n.version&&t.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=f.encode(o),m=[],x=this.localizableLayerIds&&this.localizableLayerIds.has(o);let S=!1;for(let e=0,i=0;e<n.length;e++){const s=n.feature(e),r=g.getId(s,o),a=s.properties?s.properties.worldview:null;if(x&&this.worldview&&"string"==typeof a)if("all"===a)s.properties.$localized=!0;else {if(!a.split(",").includes(this.worldview))continue;s.properties.$localized=!0,s.properties.worldview=this.worldview;}!S&&s.properties&&Object.hasOwn(s.properties,t.fP)&&(S=!0),h&&this.frcCoverage&&this.frcCoverage.frcMask&&s.properties&&t.g9&&t.g9(s.properties,this.frcCoverage.frcMask)||(m.push({feature:s,id:r,index:i,sourceLayerIndex:d}),i++);}S&&!v.elevationFeatures&&i&&(v.elevationFeatures=i(e,this.canonical));for(const e of b[o]){const i=e[0];if(this.extraShadowCaster&&(!i.is3D()||"model"===i.type))continue;if(this.renderSourceType===t.bR.Symbol&&"symbol"!==i.type)continue;if(this.renderSourceType===t.bR.FillExtrusion&&"fill-extrusion"!==i.type)continue;if(!(this.renderSourceType!==t.bR.Other&&this.renderSourceType!==t.bR.HdRoadCoverage||"symbol"!==i.type&&"fill-extrusion"!==i.type))continue;if(!this.isLayerActiveForTile(i))continue;const n=g.bucketLayerIDs.length;g.bucketLayerIDs.push(e.map(e=>t.m(e.id,e.scope)));const s=()=>{Se(e,this.zoom,v.brightness,l,this.worldview,v.activeFloors);const t=y[i.id]=i.createBucket({index:n,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceLayerName:o,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:c,worldview:this.worldview,localizable:x,availableImages:l,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});p&&p(t,this.frcCoverage?this.frcCoverage.sourceLayers:null),t.populate(m,v,this.tileID.canonical,this.tileTransform);};i.mayUse("HD")||i.mayUse("Standard")?w.push(i.prepare().then(()=>s())):s();}}const S=()=>{x.trim();const o=!(!v.elevationFeatures||!v.elevationFeatures.some(e=>e.heightRange.min<0));let i,s,a,c,p,w,b;const S={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},I=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster){this.status="done";const e=Object.values(y).filter(e=>!e.isEmpty()),t=v.elevationFeatures;h(null,{buckets:e,containsHdExt:xe(e),containsStandardExt:ve(e),featureIndex:g,collisionBoxArray:null,hasTunnelGeometry:o,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:v.brightness,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:t,glyphMap:null,iconMap:null,glyphPositions:null});}else if(s&&a&&c&&b){const e=void 0,o=new ye(s),i=new Map;for(const[e,o]of a.entries()){const{imagePosition:n}=t.fW(e,o,t.fX);i.set(e,n);}const n={};for(const e in y){const c=y[e];if(c instanceof t.bu){Se(c.layers,this.zoom,v.brightness,l,this.worldview,v.activeFloors);const u=we(this.frcCoverage,this.source,c.layers[0].sourceLayer);n[e]=Q(c,s,o.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,p,this.worldview,l,u.frcMask,u.polygons,u.tileZoom,t.g9||null,r||null);}}p.size||w.size?this.rasterizeTask=u.sendCancelable("rasterizeImages",{scope:this.scope,iconTasks:p,patternTasks:w},{},(t,i)=>{if(!t)for(const[e,t]of i.entries())a.has(e)&&a.set(e,Object.assign(a.get(e),{data:t})),c.has(e)&&c.set(e,Object.assign(c.get(e),{data:t}));P(n,o,e,b);}):P(n,o,e,b);}},P=(e,i,n,s)=>{const r=a.size>0||c.size>0,f=Object.keys(e).length>0,p=v.elevationFeatures;if(!r&&!f){this.status="done";const e=Object.values(y).filter(e=>!e.isEmpty());return void h(null,{buckets:e,containsHdExt:xe(e),containsStandardExt:ve(e),featureIndex:g,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:o,glyphAtlasImage:i.image,lineAtlas:x,imageAtlas:null,brightness:v.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:p})}const w=(n,s)=>{for(const o in y){const i=y[o];if(o in e)se(i,e[o],this.showCollisionBoxes,l,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,s);else if(i.hasPattern&&(i instanceof t.bz||i instanceof t.bA||i instanceof t.aC)){Se(i.layers,this.zoom,v.brightness,l,this.worldview,v.activeFloors);const e=Object.fromEntries(s.patternPositions);i.addFeatures(v,this.tileID.canonical,e,l,this.tileTransform,this.brightness);}}this.status="done";const r=Object.values(y).filter(e=>!e.isEmpty());h(null,{buckets:r,containsHdExt:xe(r),containsStandardExt:ve(r),featureIndex:g,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:o,glyphAtlasImage:i.image,lineAtlas:x,imageAtlas:n,brightness:v.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:p});};if(r){const e=new Map,o=t.gb(a,e),i=t.gb(c,e),n=new t.gc(o,i,s,this.lut,this.scope,e);u.send("checkAtlasCache",{descriptor:n,scope:this.scope}).then(e=>{let o,i;if(e)o=new t.gd(e.sourceHash),i=e;else {const e=new t.ge(a,c,this.lut,s,this.scope);o=e,i=e;}w(o,i);}).catch(e=>{"AbortError"!==e.name&&t.w(`[Worker] Error checking atlas cache: ${e.message}`);const o=new t.ge(a,c,this.lut,s,this.scope);w(o,o);});}else w(null,{iconPositions:new Map,patternPositions:new Map});};if(!this.extraShadowCaster){const e=t.ga(v.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?u.send("getGlyphs",{uid:this.uid,stacks:e},{metadata:S}).then(e=>{i||(s=e,I());}).catch(e=>{i||(i=e,I());}):s={},b=new Map;const o=Array.from(v.iconDependencies.keys()).map(e=>t.I.parse(e)),n=Array.from(v.patternDependencies.keys()).map(e=>t.I.parse(e));o.length||n.length?u.send("getImages",{icons:o,patterns:n,source:this.source,scope:this.scope,tileID:this.tileID},{metadata:S}).then(e=>{if(!i){a=new Map,c=new Map,p=this.updateImageMapAndGetImageTaskQueue(a,e.images,v.iconDependencies),w=this.updateImageMapAndGetImageTaskQueue(c,e.images,v.patternDependencies);for(const[t,o]of e.versions.entries())b.set(t,o);I();}}).catch(e=>{i||(i=e,I());}):(a=new Map,c=new Map,p=new Map,w=new Map);}n&&n({buckets:y,data:e,sourceLayerCoder:f,canonical:this.tileID.canonical,options:v}),I();};w.length>0?Promise.allSettled(w).then(S).catch(h):S();}updateParameters(e){this.scaleFactor=e.scaleFactor,this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.projection=e.projection,this.brightness=e.brightness,this.tileTransform=t.bp(e.tileID.canonical,e.projection),this.extraShadowCaster=e.extraShadowCaster,this.lut=e.lut,this.worldview=e.worldview,this.indoor=e.indoor,this.frcCoverage=e.frcCoverage||null,this.elevation=e.elevation||null,this.terrainEnabled=!!e.terrainEnabled;}updateImageMapAndGetImageTaskQueue(e,t,o){const i=new Map;for(const n of t.keys()){const s=o.get(n)||[];for(const o of s){const n=o.toString(),s=t.get(o.id.toString());s.usvg?i.has(n)||(i.set(n,o),e.set(n,{...s})):e.set(n,s);}}return i}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.abort();}}function Se(e,o,i,n,s,r){const a=new t.ai(o,{brightness:i,worldview:s,activeFloors:r});for(const t of e)t.recalculate(a,n);}class Ie extends t.E{constructor({actor:e,layerIndex:o,availableImages:i,availableModels:n,isSpriteLoaded:s,tileProvider:r,brightness:a,maxUniformBufferBindings:l,maxUniformBlockSizeDwords:c}){super(),this.actor=e,this.layerIndex=o,this.availableImages=i,this.availableModels=n,this.loadVectorData=t.ch,this.tileProvider=r,this.loading={},this.loaded={},this.deduped=new t.cc(e.scheduler),this.isSpriteLoaded=s,this.scheduler=e.scheduler,this.brightness=a,this.maxUniformBufferBindings=l,this.maxUniformBlockSizeDwords=c;}loadTileData(e,t){if(!this.tileProvider)return this.loadVectorData(e,t);const o=new AbortController;return this.loadTileWithProvider(this.tileProvider,e,o,t),()=>o.abort()}async loadTileWithProvider(e,t,o,i){const{z:n,x:s,y:r}=t.tileID.canonical;try{const a=await e.loadTile({z:n,x:s,y:r},{request:t.request,signal:o.signal});if(o.signal.aborted)return;if(null==a){const e=new Error("Tile not found");return e.status=404,i(e)}if(null==a.data)return i(null,null);if(a.data instanceof ImageBitmap)return i(new Error("Vector tiles require ArrayBuffer data"));const l=new Headers;a.expires&&l.set("expires",a.expires),a.cacheControl&&l.set("cache-control",a.cacheControl),i(null,{rawData:a.data,headers:l});}catch(e){if(o.signal.aborted)return;i(e instanceof Error?e:new Error(String(e)));}}_fetchTileData(e,t){return new Promise((o,i)=>{e.abort=this.loadTileData(t,(e,t)=>{e?i(e):o(t);});})}async _parse(e,t){const o=!this.isSpriteLoaded;return o&&await this.once("isSpriteLoaded"),new Promise((i,n)=>{const s=()=>e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,t)=>{e?n(e):i(t);});o&&this.scheduler?this.scheduler.add(s,{type:"parseTile",renderSourceType:t.renderSourceType,zoom:t.tileZoom}):s();})}async loadTile(e){const i=e.uid,n=e&&e.request,s=n&&n.collectResourceTiming,r=this.loading[i]=new be(e);r.maxUniformBufferBindings=this.maxUniformBufferBindings,r.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords;const a=(e,t)=>{const o=r.reloadCallback;o&&(delete r.reloadCallback,e||!t?o(e,null):r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o));};let l,c;try{l=await this._fetchTileData(r,e);}catch(e){c=e;}const u=!this.loading[i];if(delete this.loading[i],r.cancelRasterize(),c||u||!l){if(r.status="done",u||(this.loaded[i]=r),c)throw c;return null}const h=l.rawData;let d;r.vectorTile=l.vectorTile||new t.gf(new t.cB(h)),this.loaded=this.loaded||{},this.loaded[i]=r;try{d=await this._parse(r,e);}catch(e){throw a(e),e}if(!d)return a(null,null),null;const f={};if(s){const e=o(n);e.length>0&&(f.resourceTiming=JSON.parse(JSON.stringify(e)));}const g={rawTileData:h.slice(0),headers:l.headers,...d,...f};return a(null,d),g}async reloadTile(e){const t=this.loaded,o=e.uid;if(t&&t[o])return new Promise((i,n)=>{const s=t[o];s.updateParameters(e);const r=(e,t)=>{const o=s.reloadCallback;o&&(delete s.reloadCallback,s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o)),e?n(e):i(t);};"parsing"===s.status?s.reloadCallback=r:"done"===s.status?s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,r):r():i(void 0);})}abortTile(e){const t=e.uid,o=this.loading[t];o&&(o.abort&&o.abort(),delete this.loading[t]);}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}class Pe{constructor(e){this.tileProvider=e.tileProvider,this.loading={};}async loadTile(e){const o=e.uid,i=new AbortController;if(this.loading[o]={cancel:()=>i.abort()},this.tileProvider)return this.loadTileWithProvider(this.tileProvider,o,e,i);try{const{data:n,headers:s}=await t.cC(e.request,i.signal);if(!n)return null;const r=await this.decodeTile(o,n,e.encoding);return r.headers=s,r}catch(e){if(i.signal.aborted)return null;throw e}finally{delete this.loading[o];}}async decodeTile(e,o,i){const n=o instanceof ImageBitmap?o:await createImageBitmap(new Blob([new Uint8Array(o)],{type:"image/png"})),s=1-(n.width-t.gg(n.width))/2,r=s<1,a=this.getImageData(n,s);return n.close(),{dem:new t.gh(e,a,i,r),borderReady:r}}async loadTileWithProvider(e,t,o,i){const{z:n,x:s,y:r}=o.tileID.canonical;try{const a=await e.loadTile({z:n,x:s,y:r},{request:o.request,signal:i.signal});if(i.signal.aborted)return null;if(null==a){const e=new Error("Tile not found");throw e.status=404,e}if(null==a.data)return null;const l=await this.decodeTile(t,a.data,o.encoding);if(i.signal.aborted)return null;const c=new Headers;return a.expires&&c.set("expires",a.expires),a.cacheControl&&c.set("cache-control",a.cacheControl),l.headers=c,l}catch(e){if(i.signal.aborted)return null;throw e}finally{delete this.loading[t];}}async reloadTile(e){}abortTile(e){const t=e.uid,o=this.loading[t];o&&(o.cancel(),delete this.loading[t]);}removeTile(e){}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const o=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),o}}const Me=t.gi.prototype.toGeoJSON;class Te{constructor(e){this._feature=e,this.extent=t.a2,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10));}loadGeometry(){if(1===this._feature.type){const e=[];for(const o of this._feature.geometry)e.push([new t.P(o[0],o[1])]);return e}{const e=[];for(const o of this._feature.geometry){const i=[];for(const e of o)i.push(new t.P(e[0],e[1]));e.push(i);}return e}}toGeoJSON(e,t,o){return Me.call(this,e,t,o)}}class ze{constructor(e,o){this.name=e,this.extent=t.a2,this.length=o.length,this._jsonFeatures=o;}feature(e){return new Te(this._jsonFeatures[e])}}class Be{constructor(e){this.layers={},this.extent=t.a2;for(const t of Object.keys(e))this.layers[t]=new ze(t,e[t]);}}const ke=64/4096;class Ce{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const o of e){const e=o.id;if(null==e)continue;let i=this.features.get(e);i&&this.updateCache(i,t),o.geometry?(i=De(o),this.updateCache(i,t),this.features.set(e,i)):this.features.delete(e),this.updateCache(i,t);}}updateCache(e,t){for(const{canonical:o,uid:i}of Object.values(t)){const{z:n,x:s,y:r}=o;Le(e,Math.pow(2,n),s,r)&&delete t[i];}}getTile(e,t,o){const i=Math.pow(2,e),n=[];for(const e of this.features.values())Le(e,i,t,o)&&n.push(Ee(e,i,t,o));return {features:n}}getFeatures(){return [...this.features.values()]}}function Le({minX:e,minY:t,maxX:o,maxY:i},n,s,r){return e<(s+1+ke)/n&&t<(r+1+ke)/n&&o>(s-ke)/n&&i>(r-ke)/n}function De(e){const{id:t,geometry:o,properties:i}=e;if(!o)return;if("GeometryCollection"===o.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:n,coordinates:s}=o,r={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===n)Fe(s,a,r);else if("MultiPoint"===n)for(const e of s)Fe(e,a,r);else if("LineString"===n)r.type=2,Ae(s,a,r);else if("MultiLineString"===n)r.type=2,_e(s,a,r);else if("Polygon"===n)r.type=3,_e(s,a,r,!0);else {if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of s)_e(e,a,r,!0);}return r}function Fe([e,o],i,n){const s=t.a7(e);let r=t.a8(o);r=r<0?0:r>1?1:r,i.push(s,r),n.minX=Math.min(n.minX,s),n.minY=Math.min(n.minY,r),n.maxX=Math.max(n.maxX,s),n.maxY=Math.max(n.maxY,r);}function Ae(e,t,o,i=!1,n=!1){const s=[];for(const t of e)Fe(t,s,o);t.push(s),i&&function(e,t){let o=0;for(let t=0,i=e.length,n=i-2;t<i;n=t,t+=2)o+=(e[t]-e[n])*(e[t+1]+e[n+1]);if(o>0===t)for(let t=0,o=e.length;t<o/2;t+=2){const i=e[t],n=e[t+1];e[t]=e[o-2-t],e[t+1]=e[o-1-t],e[o-2-t]=i,e[o-1-t]=n;}}(s,n);}function _e(e,t,o,i=!1){for(let n=0;n<e.length;n++)Ae(e[n],t,o,i,0===n);}function Ee(e,o,i,n){const{id:s,type:r,geometry:a,tags:l}=e,c=[];if(1===r)!function(e,o,i,n,s){for(let r=0;r<e.length;r+=2){const a=Math.round(t.a2*(e[r+0]*o-i)),l=Math.round(t.a2*(e[r+1]*o-n));s.push([a,l]);}}(a,o,i,n,c);else if(2===r)for(const e of a)Oe(e,o,i,n,c);else if(3===r)for(const e of a)Re(e,o,i,n,c);return {id:s,type:r,geometry:c,tags:l}}function Oe(e,o,i,n,s){const r=-128,a=t.a2+128;let l;for(let c=0;c<e.length-2;c+=2){let u=Math.round(t.a2*(e[c+0]*o-i)),h=Math.round(t.a2*(e[c+1]*o-n)),d=Math.round(t.a2*(e[c+2]*o-i)),f=Math.round(t.a2*(e[c+3]*o-n));const g=d-u,p=f-h;u<r&&d<r||(u<r?(h+=Math.round(p*((r-u)/g)),u=r):d<r&&(f=h+Math.round(p*((r-u)/g)),d=r),h<r&&f<r||(h<r?(u+=Math.round(g*((r-h)/p)),h=r):f<r&&(d=u+Math.round(g*((r-h)/p)),f=r),u>=a&&d>=a||(u>=a?(h+=Math.round(p*((a-u)/g)),u=a):d>=a&&(f=h+Math.round(p*((a-u)/g)),d=a),h>=a&&f>=a||(h>=a?(u+=Math.round(g*((a-h)/p)),h=a):f>=a&&(d=u+Math.round(g*((a-h)/p)),f=a),l&&u===l.at(-1)[0]&&h===l.at(-1)[1]||(l=[[u,h]],s.push(l)),l.push([d,f])))));}}function Re(e,o,i,n,s){const r=(i-ke)/o,a=(n-ke)/o,l=(i+1+ke)/o,c=(n+1+ke)/o;function u(e,t){let o=0;return e<r?o|=1:e>l&&(o|=2),t<a?o|=4:t>c&&(o|=8),o}let h=[];for(let t=1;t<=8;t*=2){let o=e[e.length-2],i=e.at(-1),n=!(u(o,i)&t);for(let s=0;s<e.length;s+=2){const d=e[s],f=e[s+1],g=!(u(d,f)&t);g!==n&&(8&t?h.push(o+(d-o)*(c-i)/(f-i),c):4&t?h.push(o+(d-o)*(a-i)/(f-i),a):2&t?h.push(l,i+(f-i)*(l-o)/(d-o)):1&t&&h.push(r,i+(f-i)*(r-o)/(d-o))),g&&h.push(d,f),o=d,i=f,n=g;}if(!(e=h).length||8===t)break;h=[];}const d=[];for(let e=0;e<h.length;e+=2)d.push([Math.round(t.a2*(h[e]*o-i)),Math.round(t.a2*(h[e+1]*o-n))]);d.length&&s.push(d);}function je({name:e,features:o},i){i.writeStringField(1,e),i.writeVarintField(5,t.a2);const n=new Map,s=new Map,r={keys:n,values:s,feature:null};for(const e of o)r.feature=e,i.writeMessage(2,Ve,r);for(const e of n.keys())i.writeStringField(3,e);for(const e of s.keys())i.writeMessage(4,He,e);}function Ve(e,t){const o=e.feature;void 0!==o.id&&Number.isSafeInteger(+o.id)&&t.writeVarintField(1,+o.id),o.tags&&t.writeMessage(2,Ze,e),t.writeVarintField(3,o.type),t.writeMessage(4,Ge,o);}function Ze({keys:e,values:t,feature:o},i){for(const n of Object.keys(o.tags)){let s=o.tags[n];if(null===s)continue;let r=e.get(n);void 0===r&&(r=e.size,e.set(n,r)),i.writeVarint(r);const a=typeof s;"string"!==a&&"boolean"!==a&&"number"!==a&&(s=JSON.stringify(s));let l=t.get(s);void 0===l&&(l=t.size,t.set(s,l)),i.writeVarint(l);}}function Ne(e,t){return (t<<3)+(7&e)}function Ue(e){return e<<1^e>>31}function Ge(e,t){const{geometry:o,type:i}=e;let n=0,s=0;if(1===i){t.writeVarint(Ne(1,o.length));for(const e of o){const o=e[0]-n,i=e[1]-s;t.writeVarint(Ue(o)),t.writeVarint(Ue(i)),n+=o,s+=i;}}else for(const e of o){if(0===e.length)continue;t.writeVarint(Ne(1,1));const o=e.length-(3===i?1:0);for(let i=0;i<o;i++){1===i&&t.writeVarint(Ne(2,o-1));const r=e[i][0]-n,a=e[i][1]-s;t.writeVarint(Ue(r)),t.writeVarint(Ue(a)),n+=r,s+=a;}3===i&&t.writeVarint(Ne(7,1));}}function He(e,t){const o=typeof e;"string"===o?t.writeStringField(1,e):"boolean"===o?t.writeBooleanField(7,e):"number"===o&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e));}const Ye={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Xe=Math.fround||($e=new Float32Array(1),e=>($e[0]=+e,$e[0]));var $e;class qe{constructor(e){this.options=Object.assign(Object.create(Ye),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const s=[];for(let t=0;t<e.length;t++){const o=e[t];if(!o.geometry)continue;const[i,n]=o.geometry.coordinates,r=Xe(Qe(i)),a=Xe(Ke(n));s.push(r,a,1/0,t,-1,1),this.options.reduce&&s.push(0);}let r=this.trees[i+1]=this._createTree(s);t&&console.timeEnd(n);for(let e=i;e>=o;e--){const o=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,n=180;else if(o>n){const e=this.getClusters([o,i,180,s],t),r=this.getClusters([-180,i,n,s],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(Qe(o),Ke(s),Qe(n),Ke(i)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?Je(l,t,this.clusterProps):this.points[l[t+3]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[o];if(!n)throw new Error(i);const s=n.data;if(t*this.stride>=s.length)throw new Error(i);const r=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=n.within(s[t*this.stride],s[t*this.stride+1],r),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+5]>1?Je(s,o,this.clusterProps):this.points[s[o+3]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:s,radius:r}=this.options,a=r/s,l=(o-a)/n,c=(o+1+a)/n,u={features:[]};return this._addTileFeatures(i.range((t-a)/n,l,(t+1+a)/n,c),i.data,t,o,n,u),0===t&&this._addTileFeatures(i.range(1-a/n,l,1,c),i.data,n,o,n,u),t===n-1&&this._addTileFeatures(i.range(0,l,a/n,c),i.data,-1,o,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,n){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?n+s.point_count<=i?n+=s.point_count:n=this._appendLeaves(e,s.cluster_id,o,i,n):n<i?n++:e.push(t),e.length===o)break}return n}_createTree(e){const o=new t.d5(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)o.add(e[t],e[t+1]);return o.finish(),o.data=e,o}_addTileFeatures(e,t,o,i,n,s){for(const r of e){const e=r*this.stride,a=t[e+5]>1;let l,c,u;if(a)l=We(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+3]];l=o.properties;const[i,n]=o.geometry.coordinates;c=Qe(i),u=Ke(n);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-o)),Math.round(this.options.extent*(u*n-i))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:n,minPoints:s}=this.options,r=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;o<a.length;o+=c){if(a[o+2]<=t)continue;a[o+2]=t;const i=a[o],u=a[o+1],h=e.within(a[o],a[o+1],r),d=a[o+5];let f=d;for(const e of h){const o=e*c;a[o+2]>t&&(f+=a[o+5]);}if(f>d&&f>=s){let e,s=i*d,r=u*d,g=-1;const p=(o/c<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];s+=a[l]*u,r+=a[l+1]*u,a[l+4]=p,n&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,r/f,1/0,p,-1,f),n&&l.push(g);}else {for(let e=0;e<c;e++)l.push(a[o+e]);if(f>1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e<c;e++)l.push(a[o+e]);}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+5]>1){const i=this.clusterProps[e[t+6]];return o?Object.assign({},i):i}const i=this.points[e[t+3]].properties,n=this.options.map(i);return o&&n===i?Object.assign({},n):n}}function Je(e,t,o){return {type:"Feature",id:e[t+3],properties:We(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),et(e[t+1])]}};var i;}function We(e,t,o){const i=e[t+5],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+6],r=-1===s?{}:Object.assign({},o[s]);return Object.assign(r,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:n})}function Qe(e){return e/360+.5}function Ke(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function et(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function tt(e,t,o,i){let n=i;const s=t+(o-t>>1);let r,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;i<o;i+=3){const t=ot(e[i],e[i+1],l,c,u,h);if(t>n)r=i,n=t;else if(t===n){const e=Math.abs(i-s);e<a&&(r=i,a=e);}}n>i&&(r-t>3&&tt(e,t,r,i),e[r+2]=n,o-r>3&&tt(e,r,o,i));}function ot(e,t,o,i,n,s){let r=n-o,a=s-i;if(0!==r||0!==a){const l=((e-o)*r+(t-i)*a)/(r*r+a*a);l>1?(o=n,i=s):l>0&&(o+=r*l,i+=a*l);}return r=e-o,a=t-i,r*r+a*a}function it(e,t,o,i){const n={id:e??null,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)nt(n,o);else if("Polygon"===t)nt(n,o[0]);else if("MultiLineString"===t)for(const e of o)nt(n,e);else if("MultiPolygon"===t)for(const e of o)nt(n,e[0]);return n}function nt(e,t){for(let o=0;o<t.length;o+=3)e.minX=Math.min(e.minX,t[o]),e.minY=Math.min(e.minY,t[o+1]),e.maxX=Math.max(e.maxX,t[o]),e.maxY=Math.max(e.maxY,t[o+1]);}function st(e,t,o,i){if(!t.geometry)return;const n=t.geometry.coordinates;if(n&&0===n.length)return;const s=t.geometry.type,r=Math.pow(o.tolerance/((1<<o.maxZoom)*o.extent),2);let a=[],l=t.id;if(o.promoteId?l=t.properties[o.promoteId]:o.generateId&&(l=i||0),"Point"===s)rt(n,a);else if("MultiPoint"===s)for(const e of n)rt(e,a);else if("LineString"===s)at(n,a,r,!1);else if("MultiLineString"===s){if(o.lineMetrics){for(const o of n)a=[],at(o,a,r,!1),e.push(it(l,"LineString",a,t.properties));return}lt(n,a,r,!1);}else if("Polygon"===s)lt(n,a,r,!0);else {if("MultiPolygon"!==s){if("GeometryCollection"===s){for(const n of t.geometry.geometries)st(e,{id:l,geometry:n,properties:t.properties},o,i);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of n){const t=[];lt(e,t,r,!0),a.push(t);}}e.push(it(l,s,a,t.properties));}function rt(e,t){t.push(ct(e[0]),ut(e[1]),0);}function at(e,t,o,i){let n,s,r=0;for(let o=0;o<e.length;o++){const a=ct(e[o][0]),l=ut(e[o][1]);t.push(a,l,0),o>0&&(r+=i?(n*l-a*s)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-s,2))),n=a,s=l;}const a=t.length-3;t[2]=1,tt(t,0,a,o),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function lt(e,t,o,i){for(let n=0;n<e.length;n++){const s=[];at(e[n],s,o,i),t.push(s);}}function ct(e){return e/360+.5}function ut(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function ht(e,t,o,i,n,s,r,a){if(i/=t,s>=(o/=t)&&r<i)return e;if(r<o||s>=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const r=0===n?t.minX:t.minY,c=0===n?t.maxX:t.maxY;if(r>=o&&c<i){l.push(t);continue}if(c<o||r>=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)dt(e,u,o,i,n);else if("LineString"===s)ft(e,u,o,i,n,!1,a.lineMetrics);else if("MultiLineString"===s)pt(e,u,o,i,n,!1);else if("Polygon"===s)pt(e,u,o,i,n,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];pt(t,e,o,i,n,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(it(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(it(t.id,s,u,t.tags));}}return l.length?l:null}function dt(e,t,o,i,n){for(let s=0;s<e.length;s+=3){const r=e[s+n];r>=o&&r<=i&&mt(t,e[s],e[s+1],e[s+2]);}}function ft(e,t,o,i,n,s,r){let a=gt(e);const l=0===n?yt:xt;let c,u,h=e.start;for(let d=0;d<e.length-3;d+=3){const f=e[d],g=e[d+1],p=e[d+2],m=e[d+3],y=e[d+4],x=0===n?f:g,v=0===n?m:y;let w=!1;r&&(c=Math.sqrt(Math.pow(f-m,2)+Math.pow(g-y,2))),x<o?v>=o&&(u=l(a,f,g,m,y,o),r&&(a.start=h+c*u)):x>i?v<=i&&(u=l(a,f,g,m,y,i),r&&(a.start=h+c*u)):mt(a,f,g,p),v<o&&x>=o&&(u=l(a,f,g,m,y,o),w=!0),v>i&&x<=i&&(u=l(a,f,g,m,y,i),w=!0),!s&&w&&(r&&(a.end=h+c*u),t.push(a),a=gt(e)),r&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===n?f:g;p>=o&&p<=i&&mt(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&mt(a,a[0],a[1],a[2]),a.length&&t.push(a);}function gt(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pt(e,t,o,i,n,s){for(const r of e)ft(r,t,o,i,n,s,!1);}function mt(e,t,o,i){e.push(t,o,i);}function yt(e,t,o,i,n,s){const r=(s-t)/(i-t);return mt(e,s,o+(n-o)*r,1),r}function xt(e,t,o,i,n,s){const r=(s-o)/(n-o);return mt(e,t+(i-t)*r,s,1),r}function vt(e,t){const o=[];for(let i=0;i<e.length;i++){const n=e[i],s=n.type;let r;if("Point"===s||"MultiPoint"===s||"LineString"===s)r=wt(n.geometry,t);else if("MultiLineString"===s||"Polygon"===s){r=[];for(const e of n.geometry)r.push(wt(e,t));}else if("MultiPolygon"===s){r=[];for(const e of n.geometry){const o=[];for(const i of e)o.push(wt(i,t));r.push(o);}}o.push(it(n.id,s,r,n.tags));}return o}function wt(e,t){const o=[];o.size=e.size,void 0!==e.start&&(o.start=e.start,o.end=e.end);for(let i=0;i<e.length;i+=3)o.push(e[i]+t,e[i+1],e[i+2]);return o}function bt(e,t){if(e.transformed)return e;const o=1<<e.z,i=e.x,n=e.y;for(const s of e.features){const e=s.geometry,r=s.type;if(s.geometry=[],1===r)for(let r=0;r<e.length;r+=2)s.geometry.push(St(e[r],e[r+1],t,o,i,n));else for(let r=0;r<e.length;r++){const a=[];for(let s=0;s<e[r].length;s+=2)a.push(St(e[r][s],e[r][s+1],t,o,i,n));s.geometry.push(a);}}return e.transformed=!0,e}function St(e,t,o,i,n,s){return [Math.round(o*(e*i-n)),Math.round(o*(t*i-s))]}function It(e,t,o,i,n){const s=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),r={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:o,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const t of e)Pt(r,t,s,n);return r}function Pt(e,t,o,i){const n=t.geometry,s=t.type,r=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),"Point"===s||"MultiPoint"===s)for(let t=0;t<n.length;t+=3)r.push(n[t],n[t+1]),e.numPoints++,e.numSimplified++;else if("LineString"===s)Mt(r,n,e,o,!1,!1);else if("MultiLineString"===s||"Polygon"===s)for(let t=0;t<n.length;t++)Mt(r,n[t],e,o,"Polygon"===s,0===t);else if("MultiPolygon"===s)for(let t=0;t<n.length;t++){const i=n[t];for(let t=0;t<i.length;t++)Mt(r,i[t],e,o,!0,0===t);}if(r.length){let o=t.tags||null;if("LineString"===s&&i.lineMetrics){o={};for(const e in t.tags)o[e]=t.tags[e];o.mapbox_clip_start=n.start/n.size,o.mapbox_clip_end=n.end/n.size;}const a={geometry:r,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:o};null!==t.id&&(a.id=t.id),e.features.push(a);}}function Mt(e,t,o,i,n,s){const r=i*i;if(i>0&&t.size<(n?r:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;e<t.length;e+=3)(0===i||t[e+2]>r)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;n&&function(e,t){let o=0;for(let t=0,i=e.length,n=i-2;t<i;n=t,t+=2)o+=(e[t]-e[n])*(e[t+1]+e[n+1]);if(o>0===t)for(let t=0,o=e.length;t<o/2;t+=2){const i=e[t],n=e[t+1];e[t]=e[o-2-t],e[t+1]=e[o-1-t],e[o-2-t]=i,e[o-1-t]=n;}}(a,s),e.push(a);}const Tt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class zt{constructor(e,t){const o=(t=this.options=function(e,t){for(const o in t)e[o]=t[o];return e}(Object.create(Tt),t)).debug;if(o&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i<e.features.length;i++)st(o,e.features[i],t,i);else st(o,"Feature"===e.type?e:{geometry:e},t);return o}(e,t);this.tiles={},this.tileCoords=[],o&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),i=function(e,t){const o=t.buffer/t.extent;let i=e;const n=ht(e,1,-1-o,o,0,-1,2,t),s=ht(e,1,1-o,2+o,0,-1,2,t);return (n||s)&&(i=ht(e,1,-o,1+o,0,-1,2,t)||[],n&&(i=vt(n,1).concat(i)),s&&(i=i.concat(vt(s,-1)))),i}(i,t),i.length&&this.splitTile(i,0,0,0),o&&(i.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}splitTile(e,t,o,i,n,s,r){const a=[e,t,o,i],l=this.options,c=l.debug;for(;a.length;){i=a.pop(),o=a.pop(),t=a.pop(),e=a.pop();const u=1<<t,h=Bt(t,o,i);let d=this.tiles[h];if(!d&&(c>1&&console.time("creation"),d=this.tiles[h]=It(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==n){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===n)continue;if(null!=n){const e=n-t;if(o!==s>>e||i!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,x=null,v=null,w=null;const b=ht(e,u,o-f,o+p,0,d.minX,d.maxX,l),S=ht(e,u,o+g,o+m,0,d.minX,d.maxX,l);b&&(y=ht(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=ht(b,u,i+g,i+m,1,d.minY,d.maxY,l)),S&&(v=ht(S,u,i-f,i+p,1,d.minY,d.maxY,l),w=ht(S,u,i+g,i+m,1,d.minY,d.maxY,l)),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(x||[],t+1,2*o,2*i+1),a.push(v||[],t+1,2*o+1,2*i),a.push(w||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:n,debug:s}=i;if(e<0||e>24)return null;const r=1<<e,a=Bt(e,t=t+r&r-1,o);if(this.tiles[a])return bt(this.tiles[a],n);s>1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Bt(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?bt(this.tiles[a],n):null):null}}function Bt(e,t,o){return 32*((1<<e)*o+t)+e}function kt(e,o){const i=e.tileID.canonical;if(!this._geoJSONIndex)return void o(null,null);const n=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!n)return void o(null,null);const s=e=>e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,r=n.features.filter(e=>s(e));let a={_geojsonTileLayer:n.features};r.length>0&&(a={_geojsonTileLayer:n.features.filter(e=>!s(e)),hd_road_elevation:r});const l=new Be(a),c=function(e){const o=new t.gj;for(const t of Object.keys(e))o.writeMessage(3,je,{name:t,features:e[t]});return o.finish()}(a).buffer;o(null,{vectorTile:l,rawData:c,headers:new Headers});}class Ct extends Ie{constructor(e){super(e),this.loadVectorData=kt,this._dynamicIndex=new Ce;}async loadData(e){const i=e&&e.request,n=i&&i.collectResourceTiming;this._geoJSONIndex=null;let s=await new Promise((t,o)=>{this.loadGeoJSON(e,(e,i)=>{e?o(e):t(i);});});if(!s)return {};if("object"!=typeof s)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(e.filter){const o=t.c(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));s.features=s.features.filter(e=>o.value.evaluate({zoom:0},e));}e.dynamic?("Feature"===s.type&&(s={type:"FeatureCollection",features:[s]}),e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(s.features,this.loaded),e.cluster&&(s.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=e.cluster?new qe(function({superclusterOptions:e,clusterProperties:o}){if(!o||!e)return e;const i={},n={},s={accumulated:null,zoom:0},r={properties:null},a=Object.keys(o);for(const e of a){const[s,r]=o[e],a=t.c(r),l=t.c("string"==typeof s?[s,["accumulated"],["get",e]]:s);i[e]=a.value,n[e]=l.value;}return e.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,r);return t},e.reduce=(e,t)=>{r.properties=t;for(const t of a)s.accumulated=e[t],e[t]=n[t].evaluate(s,r);},e}(e)).load(s.features):e.dynamic?this._dynamicIndex:function(e,t){return new zt(e,t)}(s,e.geojsonVtOptions);const r={};if(n){const t=o(i);t&&(r.resourceTiming={},r.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)));}return r}async reloadTile(e){const t=this.loaded;if(t&&t[e.uid]){if(e.partial)return;return super.reloadTile(e)}return this.loadTile(e)}loadGeoJSON(e,o){if(e.request)t.g(e.request).then(({data:e})=>o(null,e)).catch(e=>o(e));else {if("string"!=typeof e.data)return o(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return o(null,JSON.parse(e.data))}catch(t){return o(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}},0);}}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}t.cA.setPbf(t.cB);class Lt{constructor(e){this._mrt=new t.cA(e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=e.uid,this.tileID=e.tileID,this.source=e.source;}async parse(e){const o=this._mrt;this.status="parsing",this._entireBuffer=e,o.parseHeader(e),this._isHeaderLoaded=!0;const i=[];for(const n in o.layers){const s=o.getLayer(n),r=s.getDataRange(s.getBandList()),a=o.createDecodingTask(r),l=e.slice(r.firstByte,r.lastByte+1);i.push(t.cA.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null)));}return await Promise.allSettled(i),o}}class Dt{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={};}async loadTile(e){const o=e.uid,i=new AbortController,n=this.loading[o]=new Lt(e);n.abort=()=>i.abort();try{const{data:s,headers:r}=await t.cC(e.request,i.signal);return s?(this.loaded[o]=n,{mrt:await n.parse(s),headers:r}):(n.status="done",this.loaded[o]=n,null)}catch(e){if(i.signal.aborted)return null;throw n.status="done",this.loaded[o]=n,e}finally{delete this.loading[o];}}async reloadTile(e){}abortTile(e){const t=e.uid,o=this.loading[t];o&&(o.abort&&o.abort(),delete this.loading[t]);}removeTile(e){const t=e.uid;this.loaded[t]&&delete this.loaded[t];}async decodeRasterArray(e){return t.cA.performDecoding(e.buffer,e.task)}}class Ft{constructor(e){this.self=e,this.actor=new t.aw(e,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=t.gl({name:"mercator"}),this.workerSourceTypes={vector:Ie,geojson:Ct,"raster-dem":Pe},this.workerSources={},this.self.registerRTLTextPlugin=e=>{if(t.fH.isParsed())throw new Error("RTL text plugin already registered.");t.fH.setState({pluginStatus:t.gm.parsed,pluginURL:t.fH.getPluginURL()}),t.fH.applyArabicShaping=e.applyArabicShaping,t.fH.processBidirectionalText=e.processBidirectionalText,t.fH.processStyledBidirectionalText=e.processStyledBidirectionalText;for(const{resolve:e}of this.rtlPluginParsingListeners)e(!0);this.rtlPluginParsingListeners=[];};}clearCaches(e,t){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],delete this.isSpriteLoaded[e];}checkIfReady(e,t){}spriteLoaded(e,o){const{scope:i}=o;if(this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.isSpriteLoaded[e][i]=!0,this.workerSources[e]&&this.workerSources[e][i])for(const o in this.workerSources[e][i]){const n=this.workerSources[e][i][o];for(const e in n){const o=n[e];o instanceof Ie&&(o.isSpriteLoaded=!0,o.fire(new t.h("isSpriteLoaded")));}}}setImages(e,t){this.availableImages[e]||(this.availableImages[e]={});const{scope:o,images:i}=t;if(this.availableImages[e][o]=i,t.isSpriteLoaded&&this.spriteLoaded(e,{scope:o}),this.workerSources[e]&&this.workerSources[e][o])for(const t in this.workerSources[e][o]){const n=this.workerSources[e][o][t];for(const e in n)n[e].availableImages=i;}}setModels(e,{scope:t,models:o}){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=o,this.workerSources[e]&&this.workerSources[e][t])for(const i in this.workerSources[e][t]){const n=this.workerSources[e][t][i];for(const e in n)n[e].availableModels=o;}}setProjection(e,o){this.projections[e]=t.gl(o);}setGlobalParams(e,o){if(this.referrer=o.referrer,Object.assign(t.eM,o.config),o.contextOptions){const{maxBindingPoints:e,maxUniformBlockSizeDwords:t}=o.contextOptions;this.maxUniformBufferBindings=e,this.maxUniformBlockSizeDwords=t;}}upsertRenderParams(e,t){void 0!==t.brightness&&(this.brightness=t.brightness),void 0!==t.worldview&&(this.worldview=t.worldview);}setLayers(e,t){this.getLayerIndex(e,t.scope).replace(t.layers,t.options);}updateLayers(e,t){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options);}async loadTile(e,o){if(o.projection=this.projections[e]||this.defaultProjection,"batched-model"===o.type&&!this.workerSourceTypes["batched-model"]){if(await t.gn(),!x)throw new Error('Could not load Standard module for "batched-model" source.');this.workerSourceTypes["batched-model"]=x;}return "raster-array"===o.type&&await this.ensureRasterArrayWorkerSource(),this.getWorkerSource(e,o).loadTile(o)}async ensureRasterArraySource(e,t){await this.ensureRasterArrayWorkerSource();}async ensureRasterArrayWorkerSource(){if(!this.workerSourceTypes["raster-array"]){if(await async function(){return Promise.resolve()}(),!Dt)throw new Error('Could not load raster-array module for "raster-array" source.');this.workerSourceTypes["raster-array"]=Dt;}}async decodeRasterArray(e,t){return await this.ensureRasterArrayWorkerSource(),this.getWorkerSource(e,t).decodeRasterArray(t)}reloadTile(e,t){return t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).reloadTile(t)}abortTile(e,t){const o=this.getExistingWorkerSource(e,t);return o?o.abortTile(t):void 0}removeTile(e,t){const o=this.getExistingWorkerSource(e,t);return o?o.removeTile(t):void 0}getExistingWorkerSource(e,t){const{type:o,source:i,scope:n}=t,s=this.workerSources[e];if(s&&s[n]&&s[n][o])return s[n][o][i]}async removeSource(e,t){const{type:o,source:i,scope:n}=t,s=this.workerSources[e]&&this.workerSources[e][n]&&this.workerSources[e][n][o],r=s&&s[i];r&&(delete s[i],r.removeSource&&await r.removeSource({source:i}));}async loadTileProvider(e,o){const i=new(await t.cn(o.name,o.url))(o.options);return this.getWorkerSource(e,{type:o.type,source:o.source,scope:o.scope},i),i.load&&o.request?i.load({request:o.request}):null}async syncRTLPluginState(e,o){if(t.fH.isParsed())return !0;if(t.fH.isParsing())return new Promise((e,t)=>{this.rtlPluginParsingListeners.push({resolve:e,reject:t});});t.fH.setState(o);const i=t.fH.getPluginURL();if(!t.fH.isLoaded()||t.fH.isParsed()||t.fH.isParsing())return !1;t.fH.setState({pluginStatus:t.gm.parsing,pluginURL:i});try{return await self.__mapboxImport(
/* webpackIgnore: true */
/* @vite-ignore */
i),!!t.fH.isParsed()||new Promise((e,t)=>{this.rtlPluginParsingListeners.push({resolve:e,reject:t});})}catch(e){t.fH.setState({pluginStatus:t.gm.error,pluginURL:i});for(const{reject:t}of this.rtlPluginParsingListeners)t(e);throw this.rtlPluginParsingListeners=[],e}}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let o=this.availableImages[e][t];return o||(o=[]),o}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let o=this.availableModels[e][t];return o||(o={}),o}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let o=this.layerIndexes[e][t];return o||(o=this.layerIndexes[e][t]=new S,o.scope=t),o}getWorkerSource(e,t,o){const{type:i,source:n,scope:s}=t,r=this.workerSources;if(r[e]||(r[e]={}),r[e][s]||(r[e][s]={}),r[e][s][i]||(r[e][s][i]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.getExistingWorkerSource(e,t))o&&(r[e][s][i][n].tileProvider=o);else {const t=this.actor.getWorkerSourceActor(e),a=this.workerSourceTypes[i];if(!a)throw new Error(`Unknown worker source type "${i}".`);r[e][s][i][n]=new a({actor:t,layerIndex:this.getLayerIndex(e,s),availableImages:this.getAvailableImages(e,s),availableModels:this.getAvailableModels(e,s),isSpriteLoaded:this.isSpriteLoaded[e][s],tileProvider:o,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});}return r[e][s][i][n]}enforceCacheSizeLimit(e,o){t.go(o);}}return t.gk(self)&&(self.worker=new Ft(self)),Ft});
define(["./shared"],function(e){const t={antialias:!1,alpha:!0,stencil:!0,depth:!0};let i,s;function r(e){const i=document.createElement("canvas"),s=Object.create(t);s.failIfMajorPerformanceCaveat=e;const r=i.getContext("webgl2",s);if(!r)return !1;let o;try{o=r.createShader(r.VERTEX_SHADER);}catch(e){return !1}return !(!o||r.isContextLost())&&(r.shaderSource(o,"void main() {}"),r.compileShader(o),!0===r.getShaderParameter(o,r.COMPILE_STATUS))}const o=/firefox/i,n=/macintosh/i;function a(e,t,i){const s=document.createElement(e);return null!=t&&(s.className=t),i&&i.appendChild(s),s}function l(e,t,i){const s=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))s.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(s),s}const c="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,h=c&&void 0!==c.userSelect?"userSelect":"WebkitUserSelect";let d;function u(){c&&h&&(d=c[h],c[h]="none");}function p(){c&&h&&(c[h]=d);}function f(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",f,!0);}function m(){window.addEventListener("click",f,!0),window.setTimeout(()=>{window.removeEventListener("click",f,!0);},0);}function _(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function g(e,t){const i=e.getBoundingClientRect(),s=[];for(let r=0;r<t.length;r++)s.push(v(e,i,t[r]));return s}function y(e){return o.test(navigator.userAgent)&&n.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function v(t,i,s){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((s.clientX-i.left)*r,(s.clientY-i.top)*r)}class b{constructor(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps=new Set,this._updatedImages=Object.create(null);}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty();}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear();}reset(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps.clear(),this._updatedImages=Object.create(null);}}class x{constructor(e){this._layer=e,this._filterDependencies=void 0;}invalidateFilter(){this._filterDependencies=void 0;}get _filterDeps(){return void 0===this._filterDependencies&&(this._filterDependencies=this._computeFilterDependencies()),this._filterDependencies}_computeFilterDependencies(){const t=this._layer;if(!t.type||"custom"===t.type||"background"===t.type||"sky"===t.type||"slot"===t.type)return null;const i=e.c(t.filter,e.s[`filter_${t.type}`]);return "error"===i.result?null:{configDependencies:i.value.configDependencies,isIndoorDependent:i.value.isIndoorDependent}}hasConfigDependency(e){const{_unevaluatedLayout:t,_transitionablePaint:i}=this._layer;if(t&&t.configDependencies.has(e))return !0;if(i&&i.configDependencies.has(e))return !0;const s=this._filterDeps;return !!s&&s.configDependencies.has(e)}get isConfigDependent(){const{_unevaluatedLayout:e,_transitionablePaint:t}=this._layer;if(e&&0!==e.configDependencies.size)return !0;if(t&&0!==t.configDependencies.size)return !0;const i=this._filterDeps;return !!i&&0!==i.configDependencies.size}get isIndoorDependent(){const{_unevaluatedLayout:e,_transitionablePaint:t}=this._layer;if(e&&e.isIndoorDependent())return !0;if(t&&t.isIndoorDependent())return !0;const i=this._filterDeps;return !!i&&i.isIndoorDependent}}function w(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const T=new e.C(0,0,0);function S(e,t){const i=[],s=e[`stretch_${t}`];let r=null;for(let e=0;e<s.length;e++)null===r?r=0===i.length?s[0]:i.at(-1)[1]+s[e]:(i.push([r,r+s[e]]),r=null);e[`stretch_${t}_areas`]=i;}function C(e,t){const i={name:void 0};let s;for(;s=e.nextField(t);)1===s?i.name=e.readString():2===s?i.metadata=E(e,e.readVarint()+e.pos):3===s&&(i.usvg_tree=P(e,e.readVarint()+e.pos),i.data="usvg_tree");return function(e){if(e.usvg_tree.height||(e.usvg_tree.height=e.usvg_tree.width),!e.metadata)return e;const{metadata:t}=e;if(t.content_area){const{content_area:i}=t;i.left??=0,i.top??=i.left,i.width??=e.usvg_tree.width,i.height??=i.width;}if(t.text_placeholder){const{text_placeholder:e}=t;e.top??=e.left,e.height??=e.width;}return t.stretch_x&&t.stretch_x.length&&S(t,"x"),t.stretch_y&&t.stretch_y.length&&S(t,"y"),e}(i)}function E(e,t){const i={stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]};let s;for(;s=e.nextField(t);)1===s?i.stretch_x=e.readPackedVarint():2===s?i.stretch_y=e.readPackedVarint():3===s?i.content_area=I(e,e.readVarint()+e.pos):4===s?i.variables.push(D(e,e.readVarint()+e.pos)):5===s&&(i.text_placeholder=I(e,e.readVarint()+e.pos));return i}function I(e,t){const i={};let s;for(;s=e.nextField(t);)1===s?i.left=e.readVarint():2===s?i.width=e.readVarint():3===s?i.top=e.readVarint():4===s&&(i.height=e.readVarint());return i}function D(e,t){const i={name:void 0};let s;for(;s=e.nextField(t);)1===s?i.name=e.readString():2===s&&(i.rgb_color=B(e.readVarint()),i.value="rgb_color");return i}function P(e,t){const i={width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[],height:20};let s;for(;s=e.nextField(t);)1===s?i.width=i.height=e.readVarint():2===s?i.height=e.readVarint():3===s?i.children.push(L(e,e.readVarint()+e.pos)):4===s?i.linear_gradients.push(k(e,e.readVarint()+e.pos)):5===s?i.radial_gradients.push(U(e,e.readVarint()+e.pos)):7===s?i.clip_paths.push(N(e,e.readVarint()+e.pos)):8===s&&i.masks.push(j(e,e.readVarint()+e.pos));return i}function L(e,t){const i={};let s;for(;s=e.nextField(t);)1===s?(i.group=R(e,e.readVarint()+e.pos),i.node="group"):2===s&&(i.path=M(e,e.readVarint()+e.pos),i.node="path");return i}function R(e,t){const i={opacity:255,children:[]};let s;for(;s=e.nextField(t);)1===s?i.transform=A(e,e.readVarint()+e.pos):2===s?i.opacity=e.readVarint():5===s?i.clip_path_idx=e.readVarint():6===s?i.mask_idx=e.readVarint():7===s&&i.children.push(L(e,e.readVarint()+e.pos));return i}function A(e,t){const i={sx:1,ky:0,kx:0,sy:1,tx:0,ty:0};let s;for(;s=e.nextField(t);)1===s?i.sx=e.readFloat():2===s?i.ky=e.readFloat():3===s?i.kx=e.readFloat():4===s?i.sy=e.readFloat():5===s?i.tx=e.readFloat():6===s&&(i.ty=e.readFloat());return i}function M(e,t){const i={paint_order:1,commands:[],step:1,diffs:[],rule:1};let s;for(;s=e.nextField(t);)1===s?i.fill=F(e,e.readVarint()+e.pos):2===s?i.stroke=O(e,e.readVarint()+e.pos):3===s?i.paint_order=e.readVarint():5===s?e.readPackedVarint(i.commands):6===s?i.step=e.readFloat():7===s?e.readPackedSVarint(i.diffs):8===s&&(i.rule=e.readVarint());return i}function F(e,t){const i={rgb_color:T,paint:"rgb_color",opacity:255};let s;for(;s=e.nextField(t);)1===s?(i.rgb_color=B(e.readVarint()),i.paint="rgb_color"):2===s?(i.linear_gradient_idx=e.readVarint(),i.paint="linear_gradient_idx"):3===s?(i.radial_gradient_idx=e.readVarint(),i.paint="radial_gradient_idx"):5===s&&(i.opacity=e.readVarint());return i}function O(e,t){const i={rgb_color:T,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1};let s;for(;s=e.nextField(t);)1===s?(i.rgb_color=B(e.readVarint()),i.paint="rgb_color"):2===s?(i.linear_gradient_idx=e.readVarint(),i.paint="linear_gradient_idx"):3===s?(i.radial_gradient_idx=e.readVarint(),i.paint="radial_gradient_idx"):5===s?e.readPackedFloat(i.dasharray):6===s?i.dashoffset=e.readFloat():7===s?i.miterlimit=e.readFloat():8===s?i.opacity=e.readVarint():9===s?i.width=e.readFloat():10===s?i.linecap=e.readVarint():11===s&&(i.linejoin=e.readVarint());return i}function B(t){return new e.C((t>>16&255)/255,(t>>8&255)/255,(255&t)/255,1)}function k(e,t){const i={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};let s;for(;s=e.nextField(t);)1===s?i.transform=A(e,e.readVarint()+e.pos):2===s?i.spread_method=e.readVarint():3===s?i.stops.push(z(e,e.readVarint()+e.pos)):4===s?i.x1=e.readFloat():5===s?i.y1=e.readFloat():6===s?i.x2=e.readFloat():7===s&&(i.y2=e.readFloat());return i}function z(e,t){const i={offset:0,opacity:255,rgb_color:T};let s;for(;s=e.nextField(t);)1===s?i.offset=e.readFloat():2===s?i.opacity=e.readVarint():3===s&&(i.rgb_color=B(e.readVarint()));return i}function U(e,t){const i={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};let s;for(;s=e.nextField(t);)1===s?i.transform=A(e,e.readVarint()+e.pos):2===s?i.spread_method=e.readVarint():3===s?i.stops.push(z(e,e.readVarint()+e.pos)):4===s?i.cx=e.readFloat():5===s?i.cy=e.readFloat():6===s?i.r=e.readFloat():7===s?i.fx=e.readFloat():8===s?i.fy=e.readFloat():9===s&&(i.fr=e.readFloat());return i}function N(e,t){const i={children:[]};let s;for(;s=e.nextField(t);)1===s?i.transform=A(e,e.readVarint()+e.pos):2===s?i.clip_path_idx=e.readVarint():3===s&&i.children.push(L(e,e.readVarint()+e.pos));return i}function j(e,t){const i={left:0,width:20,mask_type:1,children:[]};let s;for(;s=e.nextField(t);)1===s?i.left=i.top=e.readFloat():2===s?i.width=i.height=e.readFloat():3===s?i.top=e.readFloat():4===s?i.height=e.readFloat():5===s?i.mask_type=e.readVarint():6===s?i.mask_idx=e.readVarint():7===s&&i.children.push(L(e,e.readVarint()+e.pos));return i.height??=i.width,i.top??=i.left,i}class V{static calculate(t={},i=[]){const s=new Map,r=new Map;if(0===Object.keys(t).length)return s;i.forEach(t=>{r.set(t.name,t.rgb_color||new e.C(0,0,0));});for(const[e,i]of Object.entries(t))r.has(e)?s.set(r.get(e).toString(),i):console.warn(`Ignoring unknown image variable "${e}"`);return s}}function G(t,i=255,s){const r=s.get(t.toString())||t;return 255===i?r.toString():new e.C(r.r,r.g,r.b,r.a*i/255).toString()}const q=[];let Z=0;function $(t,i){if(Z>=q.length){const s=e.o()?new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});q.push(s);}const s=q[Z++];return s.canvas.width=t,s.canvas.height=i,s}function H(){Z--;}function W(e,t,i,s,r){for(const o of s.children)X(e,t,i,o,r);}function X(e,t,i,s,r){s.group?(e.save(),function(e,t,i,s,r){const o=null!=s.mask_idx?i.masks[s.mask_idx]:null,n=null!=s.clip_path_idx?i.clip_paths[s.clip_path_idx]:null;if(s.transform&&(t=re(s.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(s,null!=n,null!=o))return void W(e,t,i,s,r);const a=$(e.canvas.width,e.canvas.height);W(a,t,i,s,r),n&&ie(a,t,i,n),o&&se(a,t,i,o,r),e.globalAlpha=s.opacity/255,e.drawImage(a.canvas,0,0),H();}(e,t,i,s.group,r),e.restore()):s.path&&(e.save(),function(e,t,i,s,r){e.setTransform(t),1===s.paint_order?(K(e,i,s,r),Q(e,i,s,r)):(Q(e,i,s,r),K(e,i,s,r));}(e,t,i,s.path,r),e.restore());}function K(e,t,i,s){const r=i.fill;if(!r)return;const o=r.opacity/255;switch(e.save(),e.beginPath(),oe(i,e),r.paint){case "rgb_color":e.fillStyle=G(r.rgb_color,r.opacity,s);break;case "linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(re(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=J(e,i,o,s);break}case "radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(re(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ee(e,i,o,s);}}e.fill(Y(i)),e.restore();}function Y(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function Q(e,t,i,s){const r=i.stroke;if(!r)return;const o=ne(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const n=r.opacity/255;switch(r.paint){case "rgb_color":e.strokeStyle=G(r.rgb_color,r.opacity,s);break;case "linear_gradient_idx":e.strokeStyle=J(e,t.linear_gradients[r.linear_gradient_idx],n,s,!0);break;case "radial_gradient_idx":e.strokeStyle=ee(e,t.radial_gradients[r.radial_gradient_idx],n,s,!0);}switch(r.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel";}switch(r.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square";}e.stroke(o);}function J(e,t,i,s,r=!1){if(1===t.stops.length){const e=t.stops[0];return G(e.rgb_color,e.opacity*i,s)}const{x1:o,y1:n,x2:a,y2:l}=t;let c=new DOMPoint(o,n),h=new DOMPoint(a,l);if(r){const e=re(t.transform);c=e.transformPoint(c),h=e.transformPoint(h);}const d=e.createLinearGradient(c.x,c.y,h.x,h.y);for(const e of t.stops)d.addColorStop(e.offset,G(e.rgb_color,e.opacity*i,s));return d}function ee(e,t,i,s,r=!1){if(1===t.stops.length){const e=t.stops[0];return G(e.rgb_color,e.opacity*i,s)}const o=re(t.transform),{fx:n,fy:a,fr:l,cx:c,cy:h,r:d}=t;let u=new DOMPoint(n,a),p=new DOMPoint(c,h),f=l,m=d;if(r){u=o.transformPoint(u),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e;}const _=e.createRadialGradient(u.x,u.y,f,p.x,p.y,m);for(const e of t.stops)_.addColorStop(e.offset,G(e.rgb_color,e.opacity*i,s));return _}function te(e,t,i,s){const r=s.transform?re(s.transform).preMultiplySelf(t):t,o=$(e.canvas.width,e.canvas.height);for(const e of s.children)if(e.group)te(o,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(ne(t),r),o.fill(i,Y(t));}const n=null!=s.clip_path_idx?i.clip_paths[s.clip_path_idx]:null;n&&ie(o,r,i,n),e.globalCompositeOperation="source-over",e.drawImage(o.canvas,0,0),H();}function ie(e,t,i,s){const r=$(e.canvas.width,e.canvas.height);te(r,t,i,s),e.globalCompositeOperation="destination-in",e.drawImage(r.canvas,0,0),H();}function se(e,t,i,s,r){if(0===s.children.length)return;const o=null!=s.mask_idx?i.masks[s.mask_idx]:null;o&&se(e,t,i,o,r);const n=e.canvas.width,a=e.canvas.height,l=$(n,a),c=s.width,h=s.height,d=s.left,u=s.top,p=new Path2D,f=new Path2D;f.rect(d,u,c,h),p.addPath(f,t),l.clip(p);for(const e of s.children)X(l,t,i,e,r);const m=l.getImageData(0,0,n,a),_=m.data;if(1===s.mask_type)for(let e=0;e<_.length;e+=4)_[e+3]=_[e+3]/255*(.2126*_[e]+.7152*_[e+1]+.0722*_[e+2]);l.putImageData(m,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l.canvas,0,0),H();}function re(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function oe(e,t){const i=e.step;let s=e.diffs[0]*i,r=e.diffs[1]*i;t.moveTo(s,r);for(let o=0,n=2;o<e.commands.length;o++)switch(e.commands[o]){case 1:s+=e.diffs[n++]*i,r+=e.diffs[n++]*i,t.moveTo(s,r);break;case 2:s+=e.diffs[n++]*i,r+=e.diffs[n++]*i,t.lineTo(s,r);break;case 3:{const o=s+e.diffs[n++]*i,a=r+e.diffs[n++]*i;s=o+e.diffs[n++]*i,r=a+e.diffs[n++]*i,t.quadraticCurveTo(o,a,s,r);break}case 4:{const o=s+e.diffs[n++]*i,a=r+e.diffs[n++]*i,l=o+e.diffs[n++]*i,c=a+e.diffs[n++]*i;s=l+e.diffs[n++]*i,r=c+e.diffs[n++]*i,t.bezierCurveTo(o,a,l,c,s,r);break}case 5:t.closePath();}return t}function ne(e){return oe(e,new Path2D)}class ae{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map;}static _getImage(t){return new e.b(t,t.data)}getFromCache(t,i,s){return this.cacheMap.has(s)||this.cacheMap.set(s,new e.L(150)),this.cacheMap.get(s).get(e.m(t.toString(),i))}setInCache(t,i,s,r){this.cacheDependenciesMap.has(r)||this.cacheDependenciesMap.set(r,new Map),this.cacheMap.has(r)||this.cacheMap.set(r,new e.L(150));const o=this.cacheDependenciesMap.get(r),n=e.m(t.id.toString(),s);o.get(n)||o.set(n,new Set);const a=this.cacheMap.get(r),l=t.toString();o.get(n).add(l),a.put(e.m(t.toString(),s),i);}removeImagesFromCacheByIds(t,i,s=0){if(!this.cacheMap.has(s)||!this.cacheDependenciesMap.has(s))return;const r=this.cacheMap.get(s),o=this.cacheDependenciesMap.get(s);for(const s of t){const t=e.m(s.toString(),i);if(o.has(t)){for(const e of o.get(t))r.delete(e);o.delete(t);}}}rasterize(e,t,i,s){const r=this.getFromCache(e,i,s);if(r)return r.clone();const o=function(e,t){const i=V.calculate(t.params,e.metadata?e.metadata.variables:[]),s=e.usvg_tree,r=s.width,o=s.height,n=Math.max(1,Math.round(r*t.sx)),a=Math.max(1,Math.round(o*t.sy)),l=new DOMMatrix([n/r,0,0,a/o,0,0]),c=$(n,a);W(c,l,s,s,i);const h=c.getImageData(0,0,n,a);return H(),h}(t.icon,e),n=ae._getImage(o);return this.setInCache(e,n,i,s),n.clone()}}class le extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new e.d,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new ae;}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.b({width:1,height:1}));}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.imageVersions.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e));}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e);}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e);}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return !1;return !0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(t,e),e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images.get(t).get(e.toString())}addImage(e,t,i){if(this._validate(e,i)){this.images.get(t).set(e.toString(),i);const s=this.imageVersions.get(t),r=s.get(e.toString())||0;s.set(e.toString(),r+1);}}_validate(t,i){let s=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.f(new Error(`Image "${t.name}" has invalid "stretchX" value`))),s=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.f(new Error(`Image "${t.name}" has invalid "stretchY" value`))),s=!1),this._validateContent(i.content,i)||(this.fire(new e.f(new Error(`Image "${t.name}" has invalid "content" value`))),s=!1),s}_validateStretch(e,t){if(!e)return !0;let i=0;for(const s of e){if(s[0]<i||s[1]<s[0]||t<s[1])return !1;i=s[1];}return !0}_validateContent(e,t){if(!e)return !0;if(4!==e.length)return !1;if(!t.usvg){if(e[0]<0||t.data.width<e[0])return !1;if(e[1]<0||t.data.height<e[1])return !1;if(e[2]<0||t.data.width<e[2])return !1;if(e[3]<0||t.data.height<e[3])return !1}return !(e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i){const s=this.images.get(t).get(e.toString());i.version=s.version+1,this.images.get(t).set(e.toString(),i),this.updatedImages.get(t).add(e);const r=this.imageVersions.get(t),o=r.get(e.toString())||0;r.set(e.toString(),o+1),this.removeFromImageRasterizerCache(e,t);}clearUpdatedImages(e){this.updatedImages.get(e).clear();}removeFromImageRasterizerCache(e,t){"raster"!==this.spriteFormat&&this.imageRasterizer.removeImagesFromCacheByIds([e],t);}removeImage(e,t){const i=this.images.get(t),s=i.get(e.toString());i.delete(e.toString());const r=this.imageVersions.get(t),o=r.get(e.toString())||0;r.set(e.toString(),o+1),this.patterns.get(t).delete(e.toString()),this.removeFromImageRasterizerCache(e,t),s.userImage&&s.userImage.onRemove&&s.userImage.onRemove();}listImages(t){return Array.from(this.images.get(t).keys()).map(t=>e.I.from(t))}getImageVersions(e){return this.imageVersions.get(e)||new Map}hasImageProviderForSource(e,t){const i=this.imageProviders.get(t);if(!i)return !1;for(const t of i.values())if(t.sourceCache.getSource().id===e)return !0;return !1}getImages(e,t,i){const s=[],r=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){s.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i));}if(0===s.length)return void this._notify(r,t,i);let n=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of s)l.has(e.toString())||(n=!1);a||n?this._notify(s,t,i):this.requestors.push({ids:s,scope:t,callback:i});}rasterizeImages(e,t){const i=new Map,{iconTasks:s,patternTasks:r,scope:o}=e;for(const e of [s,r])for(const[t,s]of e.entries()){const e=this.getImage(s.id,o);e&&i.set(t,{image:e,imageVariant:s});}t(null,this._rasterizeImages(o,i));}_rasterizeImages(e,t){const i=new Map;for(const[s,{image:r,imageVariant:o}]of t.entries())i.set(s,this.imageRasterizer.rasterize(o,r,e,0));return i}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,s){const r=this.images.get(i),o=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.h("styleimagemissing",{id:i.name}));}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" 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.`);continue}const s={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(s,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),o.set(e.I.toString(i),s);}s(null,{images:o,versions:this.getImageVersions(i)});}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return {width:t,height:i}}getPattern(t,i,s){const r=t.toString(),o=this.patterns.get(i),n=o.get(r),a=this.getImage(t,i);if(!a)return null;if(n){if(n.position.version===a.version)return n.position;n.position.version=a.version;}else {if(a.usvg&&!a.data){const o=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(o))return null;this.patternsInFlight.add(o);const n=new e.i(t).scaleSelf(e.e.devicePixelRatio),l=new Map([[n.toString(),{image:a,imageVariant:n}]]),c=this._rasterizeImages(i,l);return this.storePatternImage(n,i,a,s,c),null}this.storePattern(t,i,a);}return this._updatePatternAtlas(i,s),o.get(r).position}getPatternInFlightId(t,i){return e.m(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,s,r){const o=e.toString(),n=r?r.get(o):void 0;n&&(i.data=n,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,s),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)));}storePattern(t,i,s){const r={w:s.data.width+2*e.j,h:s.data.height+2*e.j,x:0,y:0},o=new e.k(r,s,e.j);this.patterns.get(i).set(t.toString(),{bin:r,position:o});}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear();}bind(t,i){const s=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),s.RGBA8),this.atlasTexture.set(i,r)),r.bind(s.LINEAR,s.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const s=this.patterns.get(t),r=Array.from(s.values()).map(({bin:e})=>e),{w:o,h:n}=e.p(r),a=this.atlasImage.get(t);a.resize({width:o||1,height:n||1});const l=this.images.get(t);for(const[t,{bin:r,position:o}]of s.entries()){let s=o.padding;const n=r.x+s,c=r.y+s,h=l.get(t).data,d=h.width,u=h.height;s=s>1?s-1:s,e.b.copy(h,a,{x:0,y:0},{x:n,y:c},{width:d,height:u},i),e.b.copy(h,a,{x:0,y:u-s},{x:n,y:c-s},{width:d,height:s},i),e.b.copy(h,a,{x:0,y:0},{x:n,y:c+u},{width:d,height:s},i),e.b.copy(h,a,{x:d-s,y:0},{x:n-s,y:c},{width:s,height:u},i),e.b.copy(h,a,{x:0,y:0},{x:n+d,y:c},{width:s,height:u},i),e.b.copy(h,a,{x:d-s,y:u-s},{x:n-s,y:c-s},{width:s,height:s},i),e.b.copy(h,a,{x:0,y:u-s},{x:n+d,y:c-s},{width:s,height:s},i),e.b.copy(h,a,{x:0,y:0},{x:n+d,y:c+u},{width:s,height:s},i),e.b.copy(h,a,{x:d-s,y:0},{x:n-s,y:c+u},{width:s,height:s},i);}this.dirty=!0;}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set);this.imageAtlasCache.beginFrame();}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const s of e){if(this.callbackDispatchedThisFrame.get(t).has(s.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(s.toString());const e=i.get(s.toString());w(e)&&this.updateImage(s,t,e);}}}class ce{constructor(e,t,i,s){this.message=(e?`${e}: `:"")+i,s&&(this.identifier=s),null!=t&&t.__line__&&(this.line=t.__line__);}}class he extends ce{}function de(t){const i=t.value,s=t.valueSpec,r=t.style,o=t.styleSpec,n=t.key,a=t.arrayElementValidator||ze;if(!Array.isArray(i))return [new ce(n,i,`array expected, ${e.n(i)} found`)];if(s.length&&i.length!==s.length)return [new ce(n,i,`array length ${s.length} expected, length ${i.length} found`)];if(s["min-length"]&&i.length<s["min-length"])return [new ce(n,i,`array length at least ${s["min-length"]} expected, length ${i.length} found`)];let l={type:s.value,values:s.values,minimum:s.minimum,maximum:s.maximum,function:void 0};o.$version<7&&(l.function=s.function),e.l(s.value)&&(l=s.value);let c=[];for(let e=0;e<i.length;e++)c=c.concat(a({array:i,arrayIndex:e,value:i[e],valueSpec:l,style:r,styleSpec:o,key:`${n}[${e}]`},!0));return c}function ue(t){const i=t.key,s=t.value,r=t.valueSpec;if(!e.q(s))return [new ce(i,s,`number expected, ${e.n(s)} found`)];if(s!=s)return [new ce(i,s,"number expected, NaN found")];if("minimum"in r){let e=r.minimum;if(Array.isArray(r.minimum)&&(e=r.minimum[t.arrayIndex]),s<e)return [new ce(i,s,`${s} is less than the minimum value ${e}`)]}if("maximum"in r){let e=r.maximum;if(Array.isArray(r.maximum)&&(e=r.maximum[t.arrayIndex]),s>e)return [new ce(i,s,`${s} is greater than the maximum value ${e}`)]}return []}function pe(t){const i=t.key,s=t.value;if(!e.l(s))return [new ce(i,s,`object expected, ${e.n(s)} found`)];const r=t.valueSpec,o=e.u(s.type);let n,a,l,c={};const h="categorical"!==o&&void 0===s.property,d=!h,u=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.l(i[0][0])}(s),p=Ue({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(e){if("identity"===o)return [new ce(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(de({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),Array.isArray(i)&&0===i.length&&t.push(new ce(e.key,i,"array must have at least one stop")),t},default:function(e){return ze({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===o&&h&&p.push(new ce(t.key,t.value,'missing required property "property"')),"identity"===o||s.stops||p.push(new ce(t.key,t.value,'missing required property "stops"')),"exponential"===o&&r.expression&&!e.r(r)&&p.push(new ce(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(d&&!e.t(r)?p.push(new ce(t.key,t.value,"property functions not supported")):h&&!e.v(r)&&p.push(new ce(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!u||void 0!==s.property||p.push(new ce(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const s=t.value,o=t.key;if(!Array.isArray(s))return [new ce(o,s,`array expected, ${e.n(s)} found`)];if(2!==s.length)return [new ce(o,s,`array length 2 expected, length ${s.length} found`)];if(u){if(!e.l(s[0]))return [new ce(o,s,`object expected, ${e.n(s[0])} found`)];const r=s[0];if(void 0===r.zoom)return [new ce(o,s,"object stop key must have zoom")];if(void 0===r.value)return [new ce(o,s,"object stop key must have value")];const n=e.u(r.zoom);if("number"!=typeof n)return [new ce(o,r.zoom,"stop zoom values must be numbers")];if(l&&l>n)return [new ce(o,r.zoom,"stop zoom values must appear in ascending order")];n!==l&&(l=n,a=void 0,c={}),i=i.concat(Ue({key:`${o}[0]`,value:s[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:ue,value:m}}));}else i=i.concat(m({key:`${o}[0]`,value:s[0],style:t.style,styleSpec:t.styleSpec},s));return e.x(e.y(s[1]))?i.concat([new ce(`${o}[1]`,s[1],"expressions are not allowed in function stops.")]):i.concat(ze({key:`${o}[1]`,value:s[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const s=e.n(t.value),l=e.u(t.value),h=null!==t.value?t.value:i;if(n){if(s!==n)return [new ce(t.key,h,`${s} stop domain type must match previous stop domain type ${n}`)]}else n=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new ce(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==o){let i=`number expected, ${s} found`;return e.t(r)&&void 0===o&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ce(t.key,h,i)]}return "categorical"!==o||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===s&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&l<a?[new ce(t.key,h,"stop domain values must appear in ascending order")]:(a=l,"categorical"===o&&l in c?[new ce(t.key,h,"stop domain values must be unique")]:(c[l]=!0,[])):[new ce(t.key,h,`integer expected, found ${String(l)}`)]}}function fe(t){const i=("property"===t.expressionContext?e.z:e.c)(e.y(t.value),t.valueSpec);if("error"===i.result)return i.value.map(e=>new ce(`${t.key}${e.key}`,t.value,e.message));const s=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!s.outputDefined())return [new ce(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.A(s))return [new ce(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return me(s,t);if("appearance"===t.expressionContext)return ye(s,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.B(s,["zoom","feature-state"]))return [new ce(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.D(s))return [new ce(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function me(t,i){const s=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)s.delete(e);if(0===s.size)return [];const r=[];return t instanceof e.F&&s.has(t.name)?[new ce(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...me(e,i));}),r)}const _e=new Set(["get","has","properties","geometry-type","id"]),ge=new Set(["zoom","pitch","distance-from-center","feature","feature-state","measure-light","heatmap-density","line-progress","raster-value","raster-particle-speed","sky-radial-progress"]);function ye(t,i){if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)ge.delete(e);if(0===ge.size)return [];const s=[];if(t instanceof e.F){const e=_e.has(t.name)?"feature":t.name;if(ge.has(e))return [new ce(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]}return t.eachChild(e=>{s.push(...ye(e,i));}),s}function ve(t){const i=t.key,s=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?r.values.includes(e.u(s))||o.push(new ce(i,s,`expected one of [${r.values.join(", ")}], ${JSON.stringify(s)} found`)):Object.keys(r.values).includes(e.u(s))||o.push(new ce(i,s,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(s)} found`)),o}function be(t){if(e.J(e.y(t.value))){const e=t.layerType||"fill";return fe({...t,expressionContext:"filter",valueSpec:t.styleSpec[`filter_${e}`]})}return xe(t)}function xe(t){const i=t.value,s=t.key;if(!Array.isArray(i))return [new ce(s,i,`array expected, ${e.n(i)} found`)];if(i.length<1)return [new ce(s,i,"filter array must have at least 1 element")];const r=t.styleSpec;let o=ve({key:`${s}[0]`,value:i[0],valueSpec:r.filter_operator});const n=()=>{i.length>=2&&(e.H(i[1])||o.push(new ce(`${s}[1]`,i[1],`string expected, ${e.n(i[1])} found`)));for(let t=2;t<i.length;t++)"$type"===e.u(i[1])?o=o.concat(ve({key:`${s}[${t}]`,value:i[t],valueSpec:r.geometry_type})):e.H(i[t])||e.q(i[t])||e.G(i[t])||o.push(new ce(`${s}[${t}]`,i[t],`string, number, or boolean expected, ${e.n(i[t])} found.`));};switch(e.u(i[0])){case "<":case "<=":case ">":case ">=":i.length>=2&&"$type"===e.u(i[1])&&o.push(new ce(s,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&o.push(new ce(s,i,`filter array for operator "${i[0]}" must have 3 elements`)),n();break;case "==":case "!=":3!==i.length&&o.push(new ce(s,i,`filter array for operator "${i[0]}" must have 3 elements`)),n();break;case "in":case "!in":n();break;case "any":case "all":case "none":for(let e=1;e<i.length;e++)o=o.concat(xe({key:`${s}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case "has":case "!has":2!==i.length?o.push(new ce(s,i,`filter array for "${i[0]}" operator must have 2 elements`)):e.H(i[1])||o.push(new ce(`${s}[1]`,i[1],`string expected, ${e.n(i[1])} found`));}return o}const we=/^{([^}]+)}$/;function Te(t,i){const s=t.key,r=t.style,o=t.layer,n=t.styleSpec,a=t.value,l=t.objectKey,c=n[`${i}_${t.layerType}`];if(!c)return [];const h=l.match(e.U);if(h&&c[h[1]])return e.x(e.y(a))?[].concat(ze({key:s,value:a,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:r,styleSpec:n,expressionContext:"property",propertyType:i,propertyKey:l})):ze({key:s,value:a,valueSpec:{type:"string"},style:r,styleSpec:n});const d=l.match(e.K);if("paint"===i&&d&&c[d[1]]&&c[d[1]].transition)return ze({key:s,value:a,valueSpec:n.transition,style:r,styleSpec:n});const u=t.valueSpec||c[l];if(!u)return [new he(s,a,`unknown property "${l}"`)];let p;if(e.H(a)&&e.t(u)&&!u.tokens&&(p=we.exec(a))){const e=`\`{ "type": "identity", "property": ${p?JSON.stringify(p[1]):'"_"'} }\``;return [new ce(s,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${e}.`)]}const f=[];if("symbol"===t.layerType)"text-field"!==l||!r||r.glyphs||r.imports||f.push(new ce(s,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.M(e.y(a))&&"identity"===e.u(a.type)&&f.push(new ce(s,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&o&&o.layout&&Object.hasOwn(o.layout,"model-id")&&e.t(u)&&(e.N(u)||e.v(u))){const t=e.z(e.y(a),u).value,i="expression"in t&&t.expression||"_styleExpression"in t&&t._styleExpression&&t._styleExpression.expression;i&&!e.B(i,["measure-light"])&&("model-emissive-strength"===l&&e.D(i)&&e.A(i)||f.push(new ce(s,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)));}return f.concat(ze({key:t.key,value:a,valueSpec:u,style:r,styleSpec:n,expressionContext:"property",propertyType:i,propertyKey:l}))}function Se(e){return Te(e,"paint")}function Ce(e){return Te(e,"layout")}function Ee(t){let i=[];const s=t.value,r=t.key,o=t.style,n=t.styleSpec;if(!e.l(s))return [new ce(r,s,"object expected")];s.type||s.ref||i.push(new ce(r,s,'either "type" or "ref" is required'));let a=e.u(s.type);const l=e.u(s.ref);if(s.id){const n=e.u(s.id);for(let a=0;a<t.arrayIndex;a++){const t=o.layers[a];e.u(t.id)===n&&i.push(new ce(r,s.id,`duplicate layer id "${n}", previously used at line ${t.id.__line__}`));}}if("ref"in s){let t;["type","source","source-layer","filter","layout"].forEach(e=>{e in s&&i.push(new ce(r,s[e],`"${e}" is prohibited for ref layers`));}),o.layers.forEach(i=>{e.u(i.id)===l&&(t=i);}),t?t.ref?i.push(new ce(r,s.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&i.push(new ce(r,s.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(s.source)if(e.H(s.source)){const t=o.sources&&Object.hasOwn(o.sources,s.source)?o.sources[s.source]:void 0,n=t&&e.u(t.type);t?"vector"===n&&"raster"===a?i.push(new ce(r,s.source,`layer "${s.id}" requires a raster source`)):"raster"===n&&"raster"!==a?i.push(new ce(r,s.source,`layer "${s.id}" requires a vector source`)):"vector"!==n||s["source-layer"]?"raster-dem"===n&&"hillshade"!==a?i.push(new ce(r,s.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==n||["raster","raster-particle"].includes(a)?"line"===a&&s.paint&&s.paint["line-gradient"]&&"geojson"===n&&!t.lineMetrics?i.push(new ce(r,s,`layer "${s.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"line"===a&&s.paint&&s.paint["line-trim-offset"]&&"geojson"===n&&!t.lineMetrics?i.push(new ce(r,s,`layer "${s.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==n&&i.push(new ce(r,s.source,`layer "${s.id}" requires a 'raster-array' source.`)):i.push(new ce(r,s.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new ce(r,s,`layer "${s.id}" must specify a "source-layer"`)):i.push(new ce(r,s.source,`source "${s.source}" not found`));}else i.push(new ce(`${r}.source`,s.source,'"source" must be a string'));else i.push(new ce(r,s,'missing required property "source"'));return i=i.concat(Ue({key:r,value:s,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ze({key:`${r}.type`,value:s.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:s,objectKey:"type"}),filter:e=>be({layerType:a,...e}),layout:e=>Ue({layer:s,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Ce({layerType:a,...e})}}),paint:e=>Ue({layer:s,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Se({layerType:a,layer:s,...e})}}),appearances(t){const i=de({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:s,layerType:r}=t,o=e.u(t.value),n=e.u(o.name),a=e.u(o.condition),l=Ue({key:i,value:o,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...fe({key:t.key,value:t.object.condition,valueSpec:e.s.appearance.condition,expressionContext:"appearance"})),i}({...t}),properties:e=>function(e){const t=[],{styleSpec:i,layer:s,layerType:r}=e,o=i[`paint_${r}`],n=i[`layout_${r}`],a=e.object[e.objectKey];for(const i in a){const l=i in o?"paint":i in n?"layout":void 0;if(!l){t.push(new ce(e.key,i,`unknown property "${i}" for layer type "${r}"`));continue}const c={...e,key:`${e.key}.${i}`,objectKey:i,layer:s,layerType:r,value:a[i],valueSpec:"paint"===l?o[i]:n[i]};t.push(...Te(c,l));}return t}({layer:s,layerType:r,...e})}});return "hidden"!==n&&void 0===a&&l.push(new ce(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}({layerType:a,layer:s,...t})}),r=Array.isArray(t.value)?t.value:[],o=new Set;return r.forEach((r,n)=>{const a=e.u(r.name);if(a)if(o.has(a)){const r=e.u(s.id);i.push(new ce(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`));}else o.add(a);}),i}}})),i}function Ie({key:t,value:i}){return e.H(i)?[]:[new ce(t,i,`string expected, ${e.n(i)} found`)]}const De={promoteId:function t({key:i,value:s}){if(e.H(s))return Ie({key:i,value:s});if(Array.isArray(s)){const t=[],r=e.y(s),o=e.c(r);return "error"===o.result?(o.value.forEach(e=>{t.push(new ce(`${i}${e.key}`,null,`${e.message}`));}),t):(e.B(o.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new ce(`${i}`,null,"promoteId expression should be only feature dependent")),t)}if(!e.l(s))return [new ce(i,s,`string, expression or object expected, "${e.n(s)}" found`)];const r=[];for(const e in s)r.push(...t({key:`${i}.${e}`,value:s[e]}));return r}};function Pe(t){const i=t.value,s=t.key,r=t.styleSpec,o=t.style;if(!e.l(i))return [new ce(s,i,`object expected, ${e.n(i)} found`)];if(!("type"in i))return [new ce(s,i,'"type" is required')];const n=e.u(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(n)&&("url"in i||"tiles"in i||a.push(new he(s,i,'Either "url" or "tiles" is required.'))),n){case "vector":case "raster":case "raster-dem":case "raster-array":return a=a.concat(Ue({key:s,value:i,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:De})),a;case "geojson":if(a=Ue({key:s,value:i,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:De}),"cluster"in i&&"clusterProperties"in i){if(!e.l(i.clusterProperties))return [new ce(`${s}.clusterProperties`,i,`object expected, ${e.n(i)} found`)];for(const e in i.clusterProperties){const t=i.clusterProperties[e];if(!Array.isArray(t))return [new ce(`${s}.clusterProperties.${e}`,t,"array expected")];const[r,o]=t,n="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...fe({key:`${s}.${e}.map`,value:o,expressionContext:"cluster-map"})),a.push(...fe({key:`${s}.${e}.reduce`,value:n,expressionContext:"cluster-reduce"}));}}return a;case "video":return Ue({key:s,value:i,valueSpec:r.source_video,style:o,styleSpec:r});case "image":return Ue({key:s,value:i,valueSpec:r.source_image,style:o,styleSpec:r});case "canvas":return [new ce(s,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ve({key:`${s}.type`,value:i.type,valueSpec:{values:Le(r)}})}}function Le(e){return e.source.reduce((t,i)=>{const s=e[i];return "enum"===s.type.type&&(t=t.concat(Object.keys(s.type.values||{}))),t},[])}function Re(e,t){const i=!e.includes("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return !1}}function Ae(t){const i=t.value;return i?e.H(i)?Re(i,!0)?[]:[new ce(t.key,i,`invalid url "${i}"`)]:[new ce(t.key,i,`string expected, "${e.n(i)}" found`)]:[]}function Me(t){const i=t.value,s=t.styleSpec,r=s.light,o=t.style;if(void 0===i)return [];if(!e.l(i))return [new ce("light",i,`object expected, ${e.n(i)} found`)];let n=[];for(const t in i){const a=t.match(e.K),l=t.match(e.U);n=n.concat(l&&r[l[1]]?ze({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:s}):a&&r[a[1]]&&r[a[1]].transition?ze({key:t,value:i[t],valueSpec:s.transition,style:o,styleSpec:s}):r[t]?ze({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:s}):[new ce(t,i[t],`unknown property "${t}"`)]);}return n}function Fe(t){const i=t.value;if(!i)return [];const s=t.key;if(!e.l(i))return [new ce(s,i,`object expected, ${e.n(i)} found`)];let r=[];const o=t.styleSpec,n=o["light-3d"],a=t.style,l=t.style.lights;for(const e of ["type","id"])if(!(e in i))return r=r.concat([new ce(s,i,`missing property "${e}"`)]),r;if(!e.H(i.type))return r=r.concat([new ce(`${s}.type`,i.type,"string expected")]),r;if(l)for(let o=0;o<t.arrayIndex;o++){const t=e.u(i.type),n=l[o];e.u(n.type)===t&&r.push(new ce(s,i.id,`duplicate light type "${i.type}", previously defined at line ${n.id.__line__}`));}const c=`properties_light_${i.type}`;if(!(c in o))return r=r.concat([new ce(`${s}.type`,i,`Invalid light type ${i.type}`)]),r;const h=o[c];for(const s in i)if("properties"===s){const n=i[s];if(!e.l(n))return r=r.concat([new ce("properties",n,`object expected, ${e.n(n)} found`)]),r;for(const l in n){const c=l.match(e.K),d=l.match(e.U);r=r.concat(d&&h[d[1]]?ze({key:s,value:n[l],valueSpec:{type:"string"},style:a,styleSpec:o}):c&&h[c[1]]&&h[c[1]].transition?ze({key:s,value:i[s],valueSpec:o.transition,style:a,styleSpec:o}):h[l]?ze({key:l,value:n[l],valueSpec:h[l],style:a,styleSpec:o}):[new he(t.key,n[l],`unknown property "${l}"`)]);}}else r=r.concat(n[s]?ze({key:s,value:i[s],valueSpec:n[s],style:a,styleSpec:o}):[new he(s,i[s],`unknown property "${s}"`)]);return r}function Oe(t){const i=t.value,s=t.key,r=t.style,o=t.styleSpec,n=o.terrain;if(null==i)return [];if(!e.l(i))return [new ce("terrain",i,`object expected, ${e.n(i)} found`)];let a=[];for(const t in i){const s=t.match(e.K),l=t.match(e.U);a=a.concat(l&&n[l[1]]?ze({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:o}):s&&n[s[1]]&&n[s[1]].transition?ze({key:t,value:i[t],valueSpec:o.transition,style:r,styleSpec:o}):n[t]?ze({key:t,value:i[t],valueSpec:n[t],style:r,styleSpec:o}):[new he(t,i[t],`unknown property "${t}"`)]);}if(i.source)if(e.H(i.source)){const t=r.sources&&Object.hasOwn(r.sources,i.source)?r.sources[i.source]:void 0,o=t&&e.u(t.type);t?"raster-dem"!==o&&a.push(new ce(`${s}.source`,i.source,`terrain cannot be used with a source of type ${o}, it only be used with a "raster-dem" source type`)):a.push(new ce(`${s}.source`,i.source,`source "${i.source}" not found`));}else a.push(new ce(`${s}.source`,i.source,"source must be a string"));else a.push(new ce(s,i,'terrain is missing required property "source"'));return a}function Be(t){const i=t.value,s=t.style,r=t.styleSpec,o=r.fog;if(void 0===i)return [];if(!e.l(i))return [new ce("fog",i,`object expected, ${e.n(i)} found`)];let n=[];for(const t in i){const a=t.match(e.K),l=t.match(e.U);n=n.concat(l&&o[l[1]]?ze({key:t,value:i[t],valueSpec:{type:"string"},style:s,styleSpec:r}):a&&o[a[1]]&&o[a[1]].transition?ze({key:t,value:i[t],valueSpec:r.transition,style:s,styleSpec:r}):o[t]?ze({key:t,value:i[t],valueSpec:o[t],style:s,styleSpec:r}):[new he(t,i[t],`unknown property "${t}"`)]);}return n}const ke={"*":()=>[],array:de,boolean:function(t){const i=t.value,s=t.key;return e.G(i)?[]:[new ce(s,i,`boolean expected, ${e.n(i)} found`)]},number:ue,color:function({key:t,value:i}){return e.H(i)?void 0===e.C.parse(e.u(i))?[new ce(t,i,`color expected, "${i}" found`)]:[]:[new ce(t,i,`color expected, ${e.n(i)} found`)]},enum:ve,filter:be,function:pe,layer:Ee,object:Ue,source:Pe,model:Ae,light:Me,"light-3d":Fe,terrain:Oe,fog:Be,string:Ie,formatted:function(e){return 0===Ie(e).length?[]:fe(e)},resolvedImage:function(e){return 0===Ie(e).length?[]:fe(e)},projection:function(t){const i=t.value,s=t.styleSpec,r=s.projection,o=t.style;if(e.l(i)){let e=[];for(const t in i)e=e.concat(ze({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:s}));return e}return e.H(i)?[]:[new ce("projection",i,`object or string expected, ${e.n(i)} found`)]},import:function(t){const i=t.key,{value:s,styleSpec:r}=t;if(!e.l(s))return [new ce(i,s,"import must be an object")];const{data:o,...n}=s;Object.defineProperty(n,"__line__",{value:s.__line__,enumerable:!1});let a=Ue({...t,value:n,valueSpec:r.import});""===e.u(n.id)&&a.push(new ce(`${t.key}.id`,n,"import id can't be an empty string"));const l=e.u(n.id);return "__proto__"!==l&&"constructor"!==l&&"prototype"!==l||a.push(new ce(`${t.key}.id`,n,`import id can't be "${String(l)}"`)),o&&(a=a.concat(je(o,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,s=t.key,r=t.styleSpec,o=t.style;if(!e.l(i))return [new ce(s,i,"object expected")];if(!i.type)return [new ce(s,i,'"type" is required')];const n=e.u(i.type);let a=[];if(a=a.concat(Ue({key:s,value:i,valueSpec:r[`iconset_${n}`],style:o,styleSpec:r})),function(e,t){return !("source"!==e||!t.source)}(n,i)){const t=o.sources&&Object.hasOwn(o.sources,i.source)?o.sources[i.source]:void 0,r=t&&e.u(t.type);t?"raster-array"!==r&&a.push(new ce(s,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new ce(s,i.source,`source "${i.source}" not found`));}return a},option:function(t){const i=t.styleSpec,s=t.value,r=e.l(s)&&!0===e.u(s.array)||!e.l(s)?void 0:e.u(s.type);return Ue({...t,valueSpec:i.option,objectElementValidators:{default:t=>{const i=t.value;return e.l(i)?ze({...t,valueSpec:{...t.valueSpec,type:"*",expression:void 0}}):r&&Array.isArray(i)?ze({...t,valueSpec:{...t.valueSpec,type:r}}):ze(t)}}})}};function ze(t,i=!1){const s=t.value,r=t.valueSpec,o=t.styleSpec;if(r.expression){if(e.M(e.u(s)))return pe(t);if(e.x(e.y(s)))return fe(t)}if(r.type&&ke[r.type]){const e=ke[r.type](t);return !0===i&&e.length>0&&Array.isArray(t.value)?fe(t):e}return Ue({...t,valueSpec:r.type?o[r.type]:r})}function Ue(t){const i=t.key,s=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},n=t.style,a=t.styleSpec;if(!e.l(s))return [new ce(i,s,`object expected, ${e.n(s)} found`)];let l=[];for(const e in s){if(!Object.hasOwn(s,e))continue;const t=e.split(".")[0],c=Object.hasOwn(r,t),h=Object.hasOwn(r,"*"),d=c?r[t]:h?r["*"]:void 0;let u;Object.hasOwn(o,t)?u=o[t]:c?u=ze:Object.hasOwn(o,"*")?u=o["*"]:h&&(u=ze),u?l=l.concat(u({key:(i?`${i}.`:i)+e,value:s[e],valueSpec:d,style:n,styleSpec:a,object:s,objectKey:e},s)):l.push(new he(i,s[e],`unknown property "${e}"`));}for(const e in r){if(!Object.hasOwn(r,e))continue;if(Object.hasOwn(o,e))continue;const t=r[e];!t.required||void 0!==t.default||Object.hasOwn(s,e)&&void 0!==s[e]||l.push(new ce(i,s,`missing required property "${e}"`));}return l}function Ne({key:e,value:t}){const i=Ie({key:e,value:t});if(i.length)return i;const s=t;return s.includes("{fontstack}")||i.push(new ce(e,t,'"glyphs" url must include a "{fontstack}" token')),s.includes("{range}")||i.push(new ce(e,t,'"glyphs" url must include a "{range}" token')),i}function je(t,i=e.s,s={}){return Ue({key:s.key||"",value:t,valueSpec:{...i.$root,"*":{type:"*"}},styleSpec:i,style:t,objectElementValidators:{glyphs:Ne}})}function Ve(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}const Ge="setStyle",qe="addLayer",Ze="removeLayer",$e="setPaintProperty",He="setLayerProperty",We="setTerrain",Xe="removeImport",Ke="addIconset",Ye="removeIconset";function Qe(e,t,i){i.push({command:"addSource",args:[e,t[e]]});}function Je(e,t,i){t.push({command:"removeSource",args:[e]}),i[e]=!0;}function et(e,t,i,s){Je(e,i,s),Qe(e,t,i);}function tt(t,i,s){let r;for(r in t[s])if(Object.hasOwn(t[s],r)&&"data"!==r&&!e.O(t[s][r],i[s][r]))return !1;for(r in i[s])if(Object.hasOwn(i[s],r)&&"data"!==r&&!e.O(t[s][r],i[s][r]))return !1;return !0}function it(t,i,s,r,o,n){let a;for(a in i=i||{},t=t||{})Object.hasOwn(t,a)&&(e.O(t[a],i[a])||s.push({command:n,args:[r,a,i[a],o]}));for(a in i)Object.hasOwn(i,a)&&!Object.hasOwn(t,a)&&(e.O(t[a],i[a])||s.push({command:n,args:[r,a,i[a],o]}));}function st(e){return e.id}function rt(e,t){return e[t.id]=t,e}const ot=new e.C(1,0,0,1),nt=new e.C(0,1,0,1),at=new e.C(0,0,1,1),lt=new e.C(1,0,1,1),ct=new e.C(0,1,1,1);function ht(t,i,s,r,o,n,a){const l=t.context,c=t.transform,h=l.gl,d="globe"===c.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[];let p=e.Q(s.projMatrix);if(d&&e.S(c.zoom)>0){const t=e.V(s.canonical,c),i=e.W(t);p=e.X(new Float32Array(16),c.globeMatrix,i),e.X(p,c.projMatrix,p);}const f=e.Y();f[12]+=2*o/(e.e.devicePixelRatio*c.width),f[13]+=2*n/(e.e.devicePixelRatio*c.height),e.X(p,f,p);const m=t.getOrCreateProgram("debug",{defines:u}),_=i.getTileByID(s.key);t.terrain&&t.terrain.setupElevationDraw(_,m);const g=e.Z.disabled,y=e._.disabled,v=t.colorModeForRenderPass(),b="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?_._makeGlobeTileDebugBuffers(t.context,c):_._makeDebugTileBoundsBuffers(t.context,c.projection);const x=_._tileDebugBuffer||t.debugBuffer,w=_._tileDebugIndexBuffer||t.debugIndexBuffer,T=_._tileDebugSegments||t.debugSegments;if(m.draw(t,h.LINE_STRIP,g,y,v,e.$.disabled,e.a0(p,r.toPremultipliedRenderColor(null)),b,x,w,T,null,null,null,[_._globeTileDebugBorderBuffer]),a){const e=_.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=s.canonical.toString();s.overscaledZ!==s.canonical.z&&(r+=` => ${s.overscaledZ}`),r+=` ${_.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,s=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);}(t,r);}const S=i.getTile(s).tileSize,C=512/Math.min(S,512)*(s.overscaledZ/c.zoom)*.5,E=_._tileDebugTextBuffer||t.debugBuffer,I=_._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=_._tileDebugTextSegments||t.debugSegments;m.draw(t,h.TRIANGLES,g,y,e.a1.alphaBlended,e.$.disabled,e.a0(p,e.C.transparent.toPremultipliedRenderColor(null),C),b,E,I,D,null,null,null,[_._globeTileDebugTextBuffer]);}function dt(e,t,i,s){pt(e,0,t+i/2,e.transform.width,i,s);}function ut(e,t,i,s){pt(e,t-i/2,0,i,e.transform.height,s);}function pt(t,i,s,r,o,n){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.e.devicePixelRatio,s*e.e.devicePixelRatio,r*e.e.devicePixelRatio,o*e.e.devicePixelRatio),a.clear({color:n}),l.disable(l.SCISSOR_TEST);}function ft(t,i,s){const r=t.context,o=r.gl,n=s.projMatrix,a=t.getOrCreateProgram("debug"),l=i.getTileByID(s.key);t.terrain&&t.terrain.setupElevationDraw(l,a);const c=e.Z.disabled,h=e._.disabled,d=t.colorModeForRenderPass(),u="$debug";r.activeTexture.set(o.TEXTURE0),t.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);const p=l.queryGeometryDebugViz,f=l.queryBoundsDebugViz;if(p&&p.vertices.length>0){p.lazyUpload(r);const i=p.vertexBuffer,s=p.indexBuffer,l=p.segments;null!=i&&null!=s&&null!=l&&a.draw(t,o.LINE_STRIP,c,h,d,e.$.disabled,e.a0(n,p.color.toPremultipliedRenderColor(null)),u,i,s,l);}if(f&&f.vertices.length>0){f.lazyUpload(r);const i=f.vertexBuffer,s=f.indexBuffer,l=f.segments;null!=i&&null!=s&&null!=l&&a.draw(t,o.LINE_STRIP,c,h,d,e.$.disabled,e.a0(n,f.color.toPremultipliedRenderColor(null)),u,i,s,l);}}const mt=(t,i,s,r,o,n,a,l)=>{const c=e.a2/n.tileSize;return {u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:s.getCameraToCenterDistance(l),u_extrude_scale:[s.pixelsToGLUnits[0]/c,s.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:o}},_t=(e,t,i,s)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(s),u_viewport_size:[i.width,i.height]});function gt(t,i,s){const r=i.createTileMatrix(t,t.worldSize,s.toUnwrapped());return e.X(new Float32Array(16),t.projMatrix,r)}function yt(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const s=i.clone();return s.setProjection(t.projection),gt(s,t.getProjection(),e)}function vt(e,t,i){return t.name===i.projection.name?e.projMatrix:gt(i,t,e)}let bt;const xt={loaded:!0,validateStyle:function(t,i=e.s){return Ve(je(t,i))},validateSource:e=>Ve(Pe(e)),validateLight:e=>Ve(Me(e)),validateLights:e=>Ve(Fe(e)),validateTerrain:e=>Ve(Oe(e)),validateFog:e=>Ve(Be(e)),validateSnow:t=>Ve(function(t){const i=t.value,s=t.style,r=t.styleSpec,o=r.snow;if(void 0===i)return [];if(!e.l(i))return [new ce("snow",i,`object expected, ${e.n(i)} found`)];let n=[];for(const t in i){const a=t.match(e.K);n=n.concat(a&&o[a[1]]&&o[a[1]].transition?ze({key:t,value:i[t],valueSpec:r.transition,style:s,styleSpec:r}):o[t]?ze({key:t,value:i[t],valueSpec:o[t],style:s,styleSpec:r}):[new he(t,i[t],`unknown property "${t}"`)]);}return n}(t)),validateRain:t=>Ve(function(t){const i=t.value,s=t.style,r=t.styleSpec,o=r.rain;if(void 0===i)return [];if(!e.l(i))return [new ce("rain",i,`object expected, ${e.n(i)} found`)];let n=[];for(const t in i){const a=t.match(e.K);n=n.concat(a&&o[a[1]]&&o[a[1]].transition?ze({key:t,value:i[t],valueSpec:r.transition,style:s,styleSpec:r}):o[t]?ze({key:t,value:i[t],valueSpec:o[t],style:s,styleSpec:r}):[new he(t,i[t],`unknown property "${t}"`)]);}return n}(t)),validateLayer:e=>Ve(Ee(e)),validateFilter:e=>Ve(be(e)),validatePaintProperty:e=>Ve(Se(e)),validateLayoutProperty:e=>Ve(Ce(e)),validateModel:e=>Ve(Ae(e)),diffStyles:function(t,i){if(!t)return [{command:Ge,args:[i]}];let s=[];try{if(!e.O(t.version,i.version))return [{command:Ge,args:[i]}];if(e.O(t.center,i.center)||s.push({command:"setCenter",args:[i.center]}),e.O(t.zoom,i.zoom)||s.push({command:"setZoom",args:[i.zoom]}),e.O(t.bearing,i.bearing)||s.push({command:"setBearing",args:[i.bearing]}),e.O(t.pitch,i.pitch)||s.push({command:"setPitch",args:[i.pitch]}),e.O(t.sprite,i.sprite)||s.push({command:"setSprite",args:[i.sprite]}),e.O(t.glyphs,i.glyphs)||s.push({command:"setGlyphs",args:[i.glyphs]}),e.O(t.imports,i.imports)||function(t=[],i=[],s){i=i||[];const r=(t=t||[]).map(st),o=i.map(st),n=t.reduce(rt,{}),a=i.reduce(rt,{}),l=r.slice();let c,h,d,u;for(c=0,h=0;c<r.length;c++)d=r[c],Object.hasOwn(a,d)?h++:(s.push({command:Xe,args:[d]}),l.splice(l.indexOf(d,h),1));for(c=0,h=0;c<o.length;c++)d=o[o.length-1-c],l[l.length-1-c]!==d&&(Object.hasOwn(n,d)?(s.push({command:Xe,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,u=l[l.length-c],s.push({command:"addImport",args:[a[d],u]}),l.splice(l.length-c,0,d));for(const t of i){const i=n[t.id];i&&(delete i.data,e.O(i,t)||s.push({command:"updateImport",args:[t.id,t]}));}}(t.imports,i.imports,s),e.O(t.transition,i.transition)||s.push({command:"setTransition",args:[i.transition]}),e.O(t.light,i.light)||s.push({command:"setLight",args:[i.light]}),e.O(t.fog,i.fog)||s.push({command:"setFog",args:[i.fog]}),e.O(t.snow,i.snow)||s.push({command:"setSnow",args:[i.snow]}),e.O(t.rain,i.rain)||s.push({command:"setRain",args:[i.rain]}),e.O(t.projection,i.projection)||s.push({command:"setProjection",args:[i.projection]}),e.O(t.lights,i.lights)||s.push({command:"setLights",args:[i.lights]}),e.O(t.camera,i.camera)||s.push({command:"setCamera",args:[i.camera]}),e.O(t.iconsets,i.iconsets)||function(t,i,s){let r;for(r in i=i||{},t=t||{})Object.hasOwn(t,r)&&(Object.hasOwn(i,r)||s.push({command:Ye,args:[r]}));for(r in i){if(!Object.hasOwn(i,r))continue;const o=i[r];Object.hasOwn(t,r)?e.O(t[r],o)||(s.push({command:Ye,args:[r]}),s.push({command:Ke,args:[r,o]})):s.push({command:Ke,args:[r,o]});}}(t.iconsets,i.iconsets,s),!e.O(t["color-theme"],i["color-theme"]))return [{command:Ge,args:[i]}];const r={},o=[];!function(t,i,s,r){let o;for(o in i=i||{},t=t||{})Object.hasOwn(t,o)&&(Object.hasOwn(i,o)||Je(o,s,r));for(o in i){if(!Object.hasOwn(i,o))continue;const n=i[o];Object.hasOwn(t,o)?e.O(t[o],n)||("geojson"===t[o].type&&"geojson"===n.type&&tt(t,i,o)?s.push({command:"setGeoJSONSourceData",args:[o,n.data]}):et(o,i,s,r)):Qe(o,i,s);}}(t.sources,i.sources,o,r);const n=[];t.layers&&t.layers.forEach(e=>{e.source&&r[e.source]?s.push({command:Ze,args:[e.id]}):n.push(e);});let a=t.terrain;a&&r[a.source]&&(s.push({command:We,args:[void 0]}),a=void 0),s=s.concat(o),e.O(a,i.terrain)||s.push({command:We,args:[i.terrain]}),function(t,i,s){i=i||[];const r=(t=t||[]).map(st),o=i.map(st),n=t.reduce(rt,{}),a=i.reduce(rt,{}),l=r.slice(),c=Object.create(null);let h,d,u,p,f,m,_;for(h=0,d=0;h<r.length;h++)u=r[h],Object.hasOwn(a,u)?d++:(s.push({command:Ze,args:[u]}),l.splice(l.indexOf(u,d),1));for(h=0,d=0;h<o.length;h++)u=o[o.length-1-h],l[l.length-1-h]!==u&&(Object.hasOwn(n,u)?(s.push({command:Ze,args:[u]}),l.splice(l.lastIndexOf(u,l.length-d),1)):d++,m=l[l.length-h],s.push({command:qe,args:[a[u],m]}),l.splice(l.length-h,0,u),c[u]=!0);for(h=0;h<o.length;h++)if(u=o[h],p=n[u],f=a[u],!c[u]&&!e.O(p,f))if(e.O(p.source,f.source)&&e.O(p["source-layer"],f["source-layer"])&&e.O(p.type,f.type)){for(_ in it(p.layout,f.layout,s,u,null,"setLayoutProperty"),it(p.paint,f.paint,s,u,null,$e),e.O(p.slot,f.slot)||s.push({command:"setSlot",args:[u,f.slot]}),e.O(p.filter,f.filter)||s.push({command:"setFilter",args:[u,f.filter]}),e.O(p.minzoom,f.minzoom)&&e.O(p.maxzoom,f.maxzoom)||s.push({command:"setLayerZoomRange",args:[u,f.minzoom,f.maxzoom]}),p)Object.hasOwn(p,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&"slot"!==_&&(0===_.indexOf("paint.")?it(p[_],f[_],s,u,_.slice(6),$e):e.O(p[_],f[_])||s.push({command:He,args:[u,_,f[_]]}));for(_ in f)Object.hasOwn(f,_)&&!Object.hasOwn(p,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&"slot"!==_&&(0===_.indexOf("paint.")?it(p[_],f[_],s,u,_.slice(6),$e):e.O(p[_],f[_])||s.push({command:He,args:[u,_,f[_]]}));}else s.push({command:Ze,args:[u]}),m=l[l.lastIndexOf(u)+1],s.push({command:qe,args:[f,m]});}(n,i.layers,s);}catch(e){console.warn("Unable to compute style diff:",e),s=[{command:Ge,args:[i]}];}return s},drawDebug:function(t,i,s,r,o,n){for(let a=0;a<s.length;a++)if(o){const o=1,l=.8,c=new e.C(r.r*l,r.g*l,r.b*l,1);ht(t,i,s[a],r,-o,-o,n),ht(t,i,s[a],r,-o,o,n),ht(t,i,s[a],r,o,o,n),ht(t,i,s[a],r,o,-o,n),ht(t,i,s[a],c,0,0,n);}else ht(t,i,s[a],r,0,0,n);},drawDebugPadding:function(e){const t=e.transform.padding;dt(e,e.transform.height-(t.top||0),3,ot),dt(e,t.bottom||0,3,nt),ut(e,t.left||0,3,at),ut(e,e.transform.width-(t.right||0),3,lt);const i=e.transform.centerPoint;!function(e,t,i,s){pt(e,t-1,i-10,2,20,s),pt(e,t-10,i-1,20,2,s);}(e,i.x,e.transform.height-i.y,ct);},drawDebugQueryGeometry:function(e,t,i){for(let s=0;s<i.length;s++)ft(e,t,i[s]);},drawCollisionDebug:function(t,i,s,r,o,n,a){const l=t.context,c=l.gl,h=t.transform,d=[e.a7(h.center.lng),e.a8(h.center.lat)],u=s.layout.get("symbol-placement"),p=s.layout.get("text-variable-anchor"),f="map"===s.layout.get("icon-rotation-alignment"),m="map"===s.layout.get("text-rotation-alignment"),_="point"!==u,g=[];let y=0,v=0;for(let l=0;l<r.length;l++){const u=r[l],b=i.getTile(u),x=b.getBucket(s);if(!x)continue;const w=x.getProjection().createInversionMatrix(h,u.canonical),T=[],S=yt(u,x,h),C=!a&&f&&_,E=a&&m&&_,I=p&&x.hasTextData(),D=x.hasIconTextFit()&&I&&x.hasIconData(),P=C||E||a&&I||D,L="globe"===x.projection.name,R=L?e.S(h.zoom):0;L&&(T.push("PROJECTION_GLOBE_VIEW"),P&&T.push("PROJECTED_POS_ON_VIEWPORT"));const A=t.getOrCreateProgram("collisionBox",{defines:T});let M=S;0===o[0]&&0===o[1]||(M=t.translatePosMatrix(S,b,o,n));const F=a?x.textCollisionBox:x.iconCollisionBox,O=x.collisionCircleArray;if(O.length>0){const t=e.Y(),i=M;e.a9(t,x.placementInvProjMatrix,h.glCoordMatrix),e.a9(t,t,x.placementViewportMatrix),g.push({circleArray:O,circleOffset:v,transform:i,invTransform:t,projection:x.getProjection()}),y+=O.length/4,v=y;}if(!F)continue;t.terrain&&t.terrain.setupElevationDraw(b,A);const B=L?[u.canonical.x,u.canonical.y,1<<u.canonical.z]:[0,0,0];A.draw(t,c.LINES,e.Z.disabled,e._.disabled,t.colorModeForRenderPass(),e.$.disabled,mt(M,w,h,R,d,b,B,x.getProjection()),s.id,F.layoutVertexBuffer,F.indexBuffer,F.segments,null,h.zoom,null,[F.collisionVertexBuffer,F.collisionVertexBufferExt]);}if(!a||!g.length)return;const b=t.getOrCreateProgram("collisionCircle"),x=new e.aa;x.resize(4*y),x._trim();let w=0;for(const e of g)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,s=e.circleArray[i+0],r=e.circleArray[i+1],o=e.circleArray[i+2],n=e.circleArray[i+3];x.emplace(w++,s,r,o,n,0),x.emplace(w++,s,r,o,n,1),x.emplace(w++,s,r,o,n,2),x.emplace(w++,s,r,o,n,3);}(!bt||bt.length<2*y)&&(bt=function(t){const i=2*t,s=new e.ad;s.resize(i),s._trim();for(let e=0;e<i;e++){const t=6*e;s.uint16[t+0]=4*e+0,s.uint16[t+1]=4*e+1,s.uint16[t+2]=4*e+2,s.uint16[t+3]=4*e+2,s.uint16[t+4]=4*e+3,s.uint16[t+5]=4*e+0;}return s}(y));const T=l.createIndexBuffer(bt,!0),S=l.createVertexBuffer(x,e.ab.members,!0);for(const i of g){const r=_t(i.transform,i.invTransform,h,i.projection);b.draw(t,c.TRIANGLES,e.Z.disabled,e._.disabled,t.colorModeForRenderPass(),e.$.disabled,r,s.id,S,T,e.ac.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,h.zoom);}S.destroy(),T.destroy();}};async function wt(){return Promise.resolve()}function Tt(t,i){let s=!1;if(i&&i.length)for(const r of i)r instanceof he?e.w(r.message):(t.fire(new e.f(new Error(r.message))),s=!0);return s}function St(e){return (...t)=>{const i=xt[e];return i?i(...t):[]}}const Ct=St("validateStyle"),Et=St("validateSource"),It=St("validateLight"),Dt=St("validateLights"),Pt=St("validateTerrain"),Lt=St("validateFog"),Rt=St("validateSnow"),At=St("validateRain"),Mt=St("validateLayer"),Ft=St("validateFilter"),Ot=St("validatePaintProperty"),Bt=St("validateLayoutProperty"),kt=St("validateModel"),zt=e.s.light;let Ut;class Nt extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.ae(Ut||(Ut=new e.af({anchor:new e.ag(zt.anchor),position:new e.ah(zt.position),color:new e.ag(zt.color),intensity:new e.ag(zt.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(It,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,s){return (!s||!1!==s.validate)&&Tt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.s}))}}const jt=e.s.terrain;let Vt=class extends e.E{constructor(t,i,s,r,o){super(),this.scope=s,this._transitionable=new e.ae(new e.af({source:new e.ag(jt.source),exaggeration:new e.ag(jt.exaggeration)}),s,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=o;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.ai(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let s=-1,r=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.ai(t,{worldview:this.worldview})),o>.01?(s=t,r=-1):r=t;return o<.01&&s>0&&r>s?[s,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.aj}};function Gt(e,t){const i=e?e.terrain:null;return !!i&&(!t||!!t.projection.requiresDraping||!i.isZoomDependent()||i.getExaggeration(t.zoom)>0)}const qt=e.s.fog;class Zt extends e.E{constructor(t,i,s,r){super();const o=new e.af({range:new e.ag(qt.range),color:new e.ag(qt.color),"color-use-theme":new e.ag({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.ag(qt["high-color"]),"high-color-use-theme":new e.ag({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.ag(qt["space-color"]),"space-color-use-theme":new e.ag({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.ag(qt["horizon-blend"]),"star-intensity":new e.ag(qt["star-intensity"]),"vertical-range":new e.ag(qt["vertical-range"])});this._transitionable=new e.ae(o,s,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ak(o),this.scope=s;}get state(){const t=this._transform,i="globe"===t.projection.name,s=e.S(t.zoom),r=this.properties.get("range"),o=[2,4.5],n=.5/Math.tan(.5*t._fov),a=[r[0]+n,r[1]+n];return {range:i?[e.al(o[0],a[0],s),e.al(o[1],a[1],s)]:a,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Lt,e,i))return;const s={...e};for(const e of Object.keys(qt))void 0===s[e]&&(s[e]=qt[e].default);this._options=s,this._transitionable.setTransitionOrValue(this._options,t);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.am(e.ao,e.an,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?e.ap(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return e.aq(this.state,i,0,0,e.a2,e.a2,this._transform)}getOpacityForBounds(t,i,s,r,o){return this._transform.projection.supportsFog?e.aq(this.state,t,i,s,r,o,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const s of i){const i=t.points[s];let r;if(i[2]>=0)r=i;else {const o=t.points[s-4];r=e.ar(o,i,o[2]/(o[2]-i[2]));}if(e.as(this.state,r[0],r[1],0,this._transform)>=e.at)return !0}return !1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,s){return (!s||!1!==s.validate)&&Tt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.s}))}}let $t,Ht,Wt=class extends e.E{constructor(t,i,s,r){super();const o=$t||($t=new e.af({density:new e.ag(e.s.snow.density),intensity:new e.ag(e.s.snow.intensity),color:new e.ag(e.s.snow.color),opacity:new e.ag(e.s.snow.opacity),vignette:new e.ag(e.s.snow.vignette),"vignette-color":new e.ag(e.s.snow["vignette-color"]),"center-thinning":new e.ag(e.s.snow["center-thinning"]),direction:new e.ag(e.s.snow.direction),"flake-size":new e.ag(e.s.snow["flake-size"])}));this._transitionable=new e.ae(o,s,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ak(o),this.scope=s;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),s=this.properties.get("direction"),r=e.au(s[0]),o=-Math.max(e.au(s[1]),.01),n=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color"),c=new e.C(l.r,l.g,l.b,a);return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:n,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:c}}get(){return this._transitionable.serialize()}set(t,i,s={}){if(this._validate(Rt,t,s))return;const r={...t},o=e.s.snow;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,s){return (!s||!1!==s.validate)&&Tt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.s}))}},Xt=class extends e.E{constructor(t,i,s,r){super();const o=Ht||(Ht=new e.af({density:new e.ag(e.s.rain.density),intensity:new e.ag(e.s.rain.intensity),color:new e.ag(e.s.rain.color),opacity:new e.ag(e.s.rain.opacity),vignette:new e.ag(e.s.rain.vignette),"vignette-color":new e.ag(e.s.rain["vignette-color"]),"center-thinning":new e.ag(e.s.rain["center-thinning"]),direction:new e.ag(e.s.rain.direction),"droplet-size":new e.ag(e.s.rain["droplet-size"]),"distortion-strength":new e.ag(e.s.rain["distortion-strength"])}));this._transitionable=new e.ae(o,s,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ak(o),this.scope=s;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),s=this.properties.get("direction"),r=e.au(s[0]),o=-Math.max(e.au(s[1]),.01),n=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color"),l=new e.C(a.r,a.g,a.b,this.properties.get("vignette"));return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:n,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,s={}){if(this._validate(At,t,s))return;const r={...t},o=e.s.rain;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,s){return (!s||!1!==s.validate)&&Tt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.s}))}};const Kt={workerUrl:"",workerClass:null,workerParams:void 0};function Yt(e){return null!=Kt.workerClass?new Kt.workerClass:new self.Worker(Kt.workerUrl,{name:e,type:"module",...Kt.workerParams})}const Qt="mapboxgl_preloaded_worker_pool";class Jt{constructor(e){this.active={},this.workers=null,this.name=e;}acquire(e,t=Jt.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;){const t=Yt(`${this.name||""}WorkerPool: ${e}-${this.workers.length}`);this.workers.push(t);}return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach(e=>{e.terminate();}),this.workers=null);}isPreloaded(){return !!this.active[Qt]}numActive(){return Object.keys(this.active).length}}Jt.workerCount=2;class ei{constructor(t,i,s="Worker",r=Jt.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.av();const o=this.workerPool.acquire(this.id,r);for(let e=0;e<o.length;e++){const t=new ei.Actor(o[e],i,this.id);t.name=`${s} ${e}`,this.actors.push(t);}this.ready=!1,this.send("checkIfReady",null).then(()=>{this.ready=!0;}).catch(()=>{});}send(e,t,i){return Promise.all(this.actors.map(s=>s.send(e,t,i)))}broadcast(e,t){for(const i of this.actors)i.notify(e,t);}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove();}),this.actors=[],this.workerPool.release(this.id);}}ei.Actor=e.aw;class ti extends e.E{constructor(t,i,s,r){super(),this.scope=s,this._options=t,this.properties=new e.ak(i),this._transitionable=new e.ae(i,s,r),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}let ii;const si=()=>ii||(ii=new e.af({color:new e.ag(e.s.properties_light_ambient.color),"color-use-theme":new e.ag({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ag(e.s.properties_light_ambient.intensity)}));let ri;const oi=()=>ri||(ri=new e.af({direction:new e.ax(e.s.properties_light_directional.direction),color:new e.ag(e.s.properties_light_directional.color),"color-use-theme":new e.ag({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ag(e.s.properties_light_directional.intensity),"cast-shadows":new e.ag(e.s.properties_light_directional["cast-shadows"]),"shadow-quality":new e.ag(e.s.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.ag(e.s.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.ag(e.s.properties_light_directional["shadow-draw-before-layer"])})),ni=(e,t,i,s,r,o,n,a,l,c=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:s,u_camera_pos:r,u_tile_to_meter:o,u_facade_emissive_chance:n,u_flood_light_color:a,u_flood_light_intensity:l,u_front_cutoff_params:c}),ai=e=>({u_matrix:e}),li=e=>({u_matrix:e}),ci=e.ay;async function hi(){return Promise.resolve()}function di(t,i,s,r,o,n,a,l){s.resetLayerRenderingStats(t);const c=t.context,h=c.gl,d=t.transform,u=s.paint.get("fill-extrusion-pattern"),p=s.paint.get("fill-extrusion-pattern-cross-fade"),f=u.constantOr(null),m=u.constantOr(1),_=s.paint.get("fill-extrusion-opacity"),g=t.style.enable3dLights(),y=s.paint.get(g&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),v=[s.paint.get("fill-extrusion-ambient-occlusion-intensity"),y],b=s.layout.get("fill-extrusion-edge-radius"),x=b>0&&!s.paint.get("fill-extrusion-rounded-roof"),w=x?0:b,T="globe"===d.projection.name?e.aD():0,S="globe"===d.projection.name,C=S?e.S(d.zoom):0,E=[e.a7(d.center.lng),e.a8(d.center.lat)],I="none"===s.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),D=s.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(I?null:s.lut).toArray01().slice(0,3),P=s.paint.get("fill-extrusion-flood-light-intensity"),L=s.paint.get("fill-extrusion-vertical-scale"),R=0!==s.paint.get("fill-extrusion-line-width").constantOr(1),A=s.paint.get("fill-extrusion-height-alignment"),M=s.paint.get("fill-extrusion-base-alignment"),F=e.aE(t,s.paint.get("fill-extrusion-cutoff-fade-range")),O=s.paint.get("fill-extrusion-front-cutoff"),B=pi(d.pitch,O,!!t.terrain),k=B[2]<1;k&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,O[0]));const z=[];let U;S&&z.push("PROJECTION_GLOBE_VIEW"),v[0]>0&&z.push("FAUX_AO"),x&&z.push("ZERO_ROOF_RADIUS"),l&&z.push("HAS_CENTROID"),P>0&&z.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&z.push("RENDER_CUTOFF"),k&&z.push("RENDER_FRONT_CUTOFF"),R&&z.push("RENDER_WALL_MODE");const N="shadow"===t.renderPass,j=t.shadowRenderer,V=N&&!!j,G=N?e.$.disabled:e.$.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let q=[0,0,0];if(j){const i=t.style.directionalLight,s=t.style.ambientLight;i&&s&&(q=e.aF(t.style,i,s)),N||(z.push("RENDER_SHADOWS"),j.useNormalOffset&&z.push("NORMAL_OFFSET")),U=z.concat(["SHADOWS_SINGLE_CASCADE"]);}const Z=V?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",$=s.getLayerRenderingStats();for(const u of r){const r=i.getTile(u),g=r.getBucket(s);if(!g||g.projection.name!==d.projection.name)continue;let y=!1;j&&(y=0===j.getMaxCascadeForTile(u.toUnwrapped()));const b=t.isTileAffectedByFog(u),x=g.programConfigurations.get(s.id);let I=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.aG.from(f),s=i.getPrimary().scaleSelf(e.e.devicePixelRatio).toString(),o=i.getSecondary(),n=t.patternPositions.get(s),a=o?t.patternPositions.get(o.scaleSelf(e.e.devicePixelRatio).toString()):null;I=!!n&&!!a,n&&x.setConstantPatternPositions(n,a);}p>0&&(I||x.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&z.push("FILL_EXTRUSION_PATTERN_TRANSITION");const O=t.getOrCreateProgram(Z,{config:x,defines:y?U:z,overrideFog:b});if(t.terrain&&t.terrain.setupElevationDraw(r,O,{useMeterToDem:!0}),!g.centroidVertexBuffer){const e=O.getAttributeLocation(h,"a_centroid_pos");-1!==e&&h.vertexAttribI4ui(e,0,0,0,0);}!N&&j&&j.setupShadows(r.tileID.toUnwrapped(),O,"vector-tile"),m&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers());const k=s.paint.get("fill-extrusion-vertical-gradient"),V=1/g.tileToMeter;let H;if(N&&j){if(yi(r.tileID,g.maxHeight,t))continue;const i=j.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());H=e.aM(i,w,V,L,A,M);}else {const i=t.translatePosMatrix(u.expandedProjMatrix,r,s.paint.get("fill-extrusion-translate"),s.paint.get("fill-extrusion-translate-anchor")),o=d.projection.createInversionMatrix(d,u.canonical),n=O.fixedDefines.includes("LIGHTING_3D_MODE");H=m?e.aH(i,t,k,_,v,w,V,u,r,T,A,M,C,E,o,D,L,p,n):e.aI(i,t,k,_,v,w,V,u,T,A,M,C,E,o,D,L,P,q,B,n);}t.uploadCommonUniforms(c,O,u.toUnwrapped(),null,F);let W=g.segments;if("mercator"===d.projection.name&&!N&&(W=g.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!W.get().length))continue;if($)if(N)for(const e of W.get())$.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of W.get())$.numRenderedVerticesInTransparentPass+=e.primitiveLength;const X=[];(t.terrain||l)&&X.push(g.centroidVertexBuffer),S&&X.push(g.layoutVertexExtBuffer),R&&X.push(g.wallVertexBuffer),O.draw(t,c.gl.TRIANGLES,o,n,a,G,H,s.id,g.layoutVertexBuffer,g.indexBuffer,W,s.paint,t.transform.zoom,x,X);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}class ui{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0;}}function pi(e,t,i){if(!(t[2]<1)||i)return [0,0,1];const s=180*e/Math.PI;if(s<15)return [-.5,t[1],t[2]];const r=Math.min(1,Math.max(0,(s-15)/5)),o=r*r*(3-2*r);return [-.5*(1-o)+t[0]*o,t[1],t[2]]}function fi(t,i,s,r,o,n,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=n?n.findDEMTileFor(s):null;if(!(l&&l.dem||a))return;n&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.aJ?(t.flags|=e.aJ,i.flags|=e.aJ):(t.flags&=~e.aJ,i.flags&=~e.aJ);},h=t=>new e.P(Math.ceil((t+e.aK)*e.aL),0),d=(t,i,s)=>{const r=Math.ceil((t+e.aK)*e.aL),o=Math.floor(Math.max(0,Math.min(e.a2-1,s))/4);return new e.P(r,o<<5|(3&i)<<3|7)},u=e=>{const t=i.getSource().minzoom,s=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i<t)continue;const r=s(e.calculateScaledKey(e.overscaledZ+i));if(r)return r}},p=[0,0,0],f=(t,i)=>(p[0]=Math.min(t.min.y,i.min.y),p[1]=Math.max(t.max.y,i.max.y),p[2]=e.a2-i.min.x>t.max.x?i.min.x-e.a2:t.max.x,p),m=(t,i)=>(p[0]=Math.min(t.min.x,i.min.x),p[1]=Math.max(t.max.x,i.max.x),p[2]=e.a2-i.min.y>t.max.y?i.min.y-e.a2:t.max.y,p),_=[(e,t)=>f(e,t),(e,t)=>f(t,e),(e,t)=>m(e,t),(e,t)=>m(t,e)],g=(t,i,r,o,a,c,h)=>{if(!n)return 0;const d=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],u=h<0?e.a2+h:h,p=[c?u:(t+i)/2,c?(t+i)/2:u,0];return 0===r&&h<0||0!==r&&h>0?n.getForTilePoints(a,[p],!0,o):d.push(p),n.getForTilePoints(s,d,!0,l),Math.max(d[0][2],d[1][2],p[2])/n.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const o=e.aB[t](s),l=u(o);if(!(l&&l instanceof e.aC))continue;const p=n?n.findDEMTileFor(o):null;if(!(p&&p.dem||a))continue;if(n&&p&&p.dem&&r.borderDEMTileTimestamp[t]!==p.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=p.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const f=(t<2?1:5)-t,m=l.borderDoneWithNeighborZ[f]!==r.canonical.z,y=l.borderFeatureIndices[f];let v=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(m)for(const e of y)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;continue}const b=new Map,x=new Set,w=new Set;for(let e=0;e<y.length;e++){const t=l.featuresOnBorder[y[e]];void 0!==t.buildingId&&b.set(t.buildingId,e);}for(const s of i){const i=r.featuresOnBorder[s],n=r.centroidData.get(i.centroidDataIndex);if(void 0===i.buildingId)continue;const h=b.get(i.buildingId);if(void 0===h)continue;const u=l.featuresOnBorder[y[h]],m=l.centroidData.get(u.centroidDataIndex);x.add(s),w.add(h),a&&c(n,m);const v=0!==n.groupCentroidPos.x||0!==n.groupCentroidPos.y?n.groupCentroidPos:i.centroid(),T=0!==m.groupCentroidPos.x||0!==m.groupCentroidPos.y?m.groupCentroidPos:u.centroid(),S=t<2?Math.round((v.y+T.y)/2):Math.round((v.x+T.x)/2),C=i.intersectsCount()>1||u.intersectsCount()>1;{let i=0;if(p&&p.dem&&!C){const s=_[t](n,m),r=t%2?e.a2-1:0;i=g(s[0],Math.min(e.a2-1,s[1]),r,p,o,t<2,s[2]);}n.centroidXY=d(i,t,S),m.centroidXY=d(i,f,S);}if(r.writeCentroidToBuffer(n),l.writeCentroidToBuffer(m),void 0!==i.buildingId){for(const e of r.centroidData)e.buildingId===i.buildingId&&e!==n&&(e.centroidXY=n.centroidXY,r.writeCentroidToBuffer(e));for(const e of l.centroidData)e.buildingId===i.buildingId&&e!==m&&(e.centroidXY=m.centroidXY,l.writeCentroidToBuffer(e));}}for(const s of i){if(x.has(s))continue;const i=r.featuresOnBorder[s],n=r.centroidData.get(i.centroidDataIndex),d=i.borders[t];let u;for(;v<y.length;){if(w.has(v)){v++;continue}u=l.featuresOnBorder[y[v]];const e=u.borders[f];if(e[1]>d[0]+3||e[0]>d[0]-3)break;l.showCentroid(u),v++;}if(u&&v<y.length){let s=v,m=0;for(;;)if(w.has(v)){if(++v===y.length)break;u=l.featuresOnBorder[y[v]];}else {if(u.borders[f][0]>d[1]-3)break;if(m++,++v===y.length)break;u=l.featuresOnBorder[y[v]];}for(;s<y.length&&w.has(s);)s++;if(s>=y.length){r.showCentroid(i);continue}u=l.featuresOnBorder[y[s]];let b=!1;if(m>=1){const e=u.borders[f];Math.abs(d[0]-e[0])<3&&Math.abs(d[1]-e[1])<3&&(m=1,b=!0,v=s+1);}else if(0===m){r.showCentroid(i);continue}const x=l.centroidData.get(u.centroidDataIndex);a&&b&&c(n,x);const T=i.intersectsCount()>1||u.intersectsCount()>1;if(m>1)v=s,n.centroidXY=x.centroidXY=new e.P(0,0);else if(p&&p.dem&&!T){const i=_[t](n,x),s=t%2?e.a2-1:0,r=g(i[0],Math.min(e.a2-1,i[1]),s,p,o,t<2,i[2]);n.centroidXY=x.centroidXY=h(r);}else T?n.centroidXY=x.centroidXY=new e.P(0,0):(n.centroidXY=r.encodeBorderCentroid(i),x.centroidXY=l.encodeBorderCentroid(u));r.writeCentroidToBuffer(n),l.writeCentroidToBuffer(x);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const mi=[1,0,0],_i=[0,1,0],gi=[0,0,1];function yi(t,i,s){const r=s.transform,o=s.shadowRenderer;if(!o)return !0;const n=s.frameCounter,a=s.currentShadowCascade;let l=s._shadowCullCache;if(!l||l.frame!==n||l.cascade!==a){const t=r.tileSize*o._cascades[a].scale,i=r.scaleZoom(t),c=o.shadowDirection,h=[c[0],c[1],-c[2]],d=[mi,_i,gi,h,[h[0],0,h[2]],[0,h[1],h[2]]];l={frame:n,cascade:a,cameraFrustum:e.az.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,i,!("globe"===r.projection.name)),edges:d,shadowDir:h,ws:t,zoom:i},s._shadowCullCache=l;}const{cameraFrustum:c,edges:h,shadowDir:d,ws:u,zoom:p}=l;let f=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(f+=e.max);}f/=e.aA(r.center.lat,p);const m=o.computeSimplifiedTileShadowVolume(t.toUnwrapped(),f,u,d);if(!m)return !1;const{vertices:_,planes:g}=m;return 0===c.intersectsPrecise(_,g,h)||0===o.getCurrentCascadeFrustum().intersectsPrecise(_,g,h)}const vi=new Float32Array(16),bi=new Float32Array(16);function xi(t){const{painter:i,source:s,layer:r,coords:o}=t;let n=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,h=i.shadowRenderer,d=e.aA(i.transform.center.lat,i.transform.zoom),u=e.aE(i,r.paint.get("building-cutoff-fade-range"));u.shouldRenderCutoff&&(n=n.concat("RENDER_CUTOFF"));const p=r.paint.get("building-front-cutoff"),f=p[2]<1&&!i.terrain,m=pi(i.transform.pitch,p,!!i.terrain);f&&(n=n.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,p[0])),t.floodLightIntensity>0&&(n=n.concat("FLOOD_LIGHT"));for(const p of o){const o=s.getTile(p),f=o.getBucket(r);if(!f)continue;h&&0===h.getMaxCascadeForTile(p.toUnwrapped())&&(n=n.concat("SHADOWS_SINGLE_CASCADE"));const _=f.programConfigurations.get(r.id);let g,y;const v=i.translatePosMatrix(p.expandedProjMatrix,o,[0,0],"map");e.aN(vi,v,[1,1,t.verticalScale]);const b=vi;let x;if(l&&h){if(yi(o.tileID,f.maxHeight*d,i))continue;const s=h.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());e.aN(s,s,[1,1,t.verticalScale]),x=li(s),g=y=i.getOrCreateProgram("buildingDepth",{config:_,defines:n,overrideFog:!1});}else if(c)g=y=i.getOrCreateProgram("buildingBloom",{config:_,defines:n,overrideFog:!1}),x=ai(b);else {const s=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.aN(s,s,[1,1,t.verticalScale]),e.aN(bi,s,[1,-1,1/d]),e.aO(bi,bi),e.aP(bi,bi);const r=bi,o=i.transform.getFreeCameraOptions().position,l=1<<p.canonical.z;if(x=ni(b,r,t.opacity,t.facadeAOIntensity,[((o.x-p.wrap)*l-p.canonical.x)*e.a2,(o.y*l-p.canonical.y)*e.a2,o.z*l*e.a2],f.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,m),y=i.getOrCreateProgram("building",{config:_,defines:n,overrideFog:!1}),!0===t.depthOnly)g=y;else {const e=n.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=i.getOrCreateProgram("building",{config:_,defines:e,overrideFog:!1});}h&&(h.setupShadowsFromMatrix(s,y,!0),g!==y&&g.setShadowUniformValues(a,h.getShadowUniformValues()));}const w=(s,o)=>{if(c){const n=s.entranceBloom;o.draw(i,a.gl.TRIANGLES,t.depthMode,e._.disabled,t.blendMode,e.$.disabled,x,r.id,n.layoutVertexBuffer,n.indexBuffer,n.segmentsBucket,r.paint,i.transform.zoom,_,[n.layoutAttenuationBuffer,n.layoutColorBuffer]);}else {const n=s.segmentsBucket;let c=[s.layoutNormalBuffer,s.layoutCentroidBuffer,s.layoutColorBuffer,s.layoutFloodLightDataBuffer];s.layoutFacadePaintBuffer&&(c=c.concat([s.layoutFacadeDataBuffer,s.layoutFacadeVerticalRangeBuffer,s.layoutFacadePaintBuffer])),o.draw(i,a.gl.TRIANGLES,t.depthMode,e._.disabled,t.blendMode,l?e.$.disabled:e.$.backCW,x,r.id,s.layoutVertexBuffer,s.indexBuffer,n,r.paint,i.transform.zoom,_,c);}};i.uploadCommonUniforms(a,y,p.toUnwrapped(),null,u),f.buildingWithoutFacade&&w(f.buildingWithoutFacade,y),f.buildingWithFacade&&(g!==y&&i.uploadCommonUniforms(a,g,p.toUnwrapped(),null,u),w(f.buildingWithFacade,g));}}function wi(t,i,s,r,o,n,a,l,c,h,d,u,p,f){const m=t.context.gl,_=t.depthModeForSublayer(1,e.Z.ReadOnly,m.LEQUAL,!0),g=e.al(.1,3,d),y=t._showOverdrawInspector,v=u,b=new ui;if(!y){const d=new e._({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),u=new e.a1([m.ONE,m.ONE,m.ONE,m.ONE],e.C.transparent,[!1,!1,!1,!0],m.MIN);e.aQ(b,t,i,s,r,_,d,u,e.$.disabled,o,"sdf",n,a,l,c,h,g,v,!1,void 0);}{const d=y?e._.disabled:new e._({func:m.EQUAL,mask:255},255,255,m.KEEP,m.DECR,m.DECR),u=y?t.colorModeForRenderPass():new e.a1([m.ONE_MINUS_DST_ALPHA,m.DST_ALPHA,m.ONE,m.ONE],e.C.transparent,[!0,!0,!0,!0]);e.aQ(b,t,i,s,r,_,d,u,e.$.disabled,o,"color",n,a,l,c,h,g,v,!1,void 0);}}class Ti{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16;}findClosestBuilding(e,t,i,s,r){if(i<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let o=null,n=Number.MAX_VALUE,a=Number.MAX_VALUE,l=!1;const c=this._previousClosestBuildingId?e[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&c&&this._isBuildingVisible(c,s,r)&&(l=!0,a=this._calculateDistance(t,c));for(const[i,a]of Object.entries(e)){if(!this._isBuildingVisible(a,s,r))continue;const e=this._calculateDistance(t,a);e<n&&(n=e,o=i);}return l&&o&&this._previousClosestBuildingId&&o!==this._previousClosestBuildingId?n>a*this._hysteresisRatio&&(o=this._previousClosestBuildingId):l&&!o&&(o=this._previousClosestBuildingId),this._previousClosestBuildingId=o,o}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],s=e.lng-t.center[0];return i*i+s*s}_isBuildingVisible(t,i,s){if(!s)return !1;for(const i of t.floorIds){const r=t.floors[i];if(!r.geometry)continue;const o=r.geometry;if("Polygon"===o.type){const t=this._convertRingToPoints(o.coordinates[0]);if(e.aT(t,s))return !0}else if("MultiPolygon"===o.type){const t=this._convertMultiPolygonToPoints(o.coordinates);if(e.aU(s,t))return !0}}return !1}_convertRingToPoints(t){return t.map(t=>new e.P(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.P(t[0],t[1])))}}const Si=.05,Ci=(e,t,i,s,r,o,n,a,l,c,h,d)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:s,u_grid_matrix:r,u_tl_parent:o,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:n,u_merc_center:a,u_cutoff_params:l}),Ei=(e,t,i,s,r,o,n,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:s,u_color_ramp:o,u_velocity_res:r,u_max_speed:n,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Si,Si]}),Ii=(e,t,i,s,r,o,n,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:s,u_max_speed:r,u_speed_factor:o,u_reset_rate:n,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Si,Si]});function Di(e,[t,i,s,r],[o,n]){if(o===n)return [0,0,0,0];const a=255*(e-1)/(e*(n-o));return [t*a,i*a,s*a,r*a]}function Pi(e,t,[i,s]){return i===s?0:.5/e+(t-i)*(e-1)/(e*(s-i))}var Li=e.a_([{name:"a_index",type:"Int16",components:1}]);class Ri{constructor(t,i,s,r){const o={width:s[0],height:s[1],data:null},n=t.gl;this.targetColorTexture=new e.T(t,o,n.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,n.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0;}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const s=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,s.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,s.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.a$;o.reserve(r);for(let e=0;e<r;e++)o.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(o,Li.members,!0),this.particleSegment=e.ac.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width;}update(t){return !(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.e.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy();}}function Ai(t,i,s,r,o){if(o>0){const n=e.e.now(),a=(n-t.timeAdded)/o,l=i?(n-i.timeAdded)/o:-1,c=s.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),u=d&&t.refreshedUponExpiration?1:e.b0(d?a:1-l,0,1);return i?{opacity:1,mix:1-u,isFading:a<1}:{opacity:u,mix:0,isFading:a<1}}return {opacity:1,mix:0,isFading:!1}}function Mi(t,i,s){if(!t)return null;const r=i.getTextureDescriptor(t,s,!0);if(!r)return null;let{texture:o,mix:n,offset:a,tileSize:l,buffer:c,format:h}=r;if(!o||!h)return null;let d=!1;return "uint32"===h&&(d=!0,n[3]=0,n=Di(e.b9,n,[0,s.paint.get("raster-particle-max-speed")]),a=Pi(e.b9,a,[0,s.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:d,scale:n,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function Fi(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),s=i-t,r=.2*e.height,o=t+r;return [t,i,(o-r-t)/s,(o-t)/s]}var Oi="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}";e.ba["_prelude_raster_particle.glsl"]||(e.ba["_prelude_raster_particle.glsl"]=Oi);var Bi={building:e.bb('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:e.bb("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:e.bb("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:e.bb('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:e.bb("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:e.bb("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_tex_pos.y=1.0-v_tex_pos.y;\n#endif\ngl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:e.bb('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:e.bb("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:e.bb("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:e.bb("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),elevatedStructuresDepth:e.bb("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructures:e.bb('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;uniform float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,v_height);\n#endif\nout_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),elevatedStructuresDepthReconstruct:e.bb('#include "_prelude_feature_cutout.fragment.glsl"\n#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}',"in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}")};e.bb(Oi,"");const ki=e.a_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),zi=e.a_([{type:"Float32",name:"a_pos_2f",components:2}]);class Ui{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy();}draw(t,i){const s=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.bc,s=new e.ad;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),s.emplaceBack(0,1,2),s.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,zi.members),this.vignetteIdx=t.context.createIndexBuffer(s);}const r=e.ac.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,s);const n={u_vignetteShape:(o={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:o.vignetteColor};s.draw(t,t.context.gl.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.alphaBlended,e.$.disabled,n,"vignette",this.vignetteVx,this.vignetteIdx,r);}var o;}}class Ni{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;}update(t,i){const s=t.getFreeCameraOptions().position,r=s.toAltitude(),o=s.toLngLat(),n=e.au(o.lng),a=e.au(o.lat),l=t.pixelsPerMeter/i,c=n*e.bj,h=e.bj*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else {const e=-this._offsetYPrev+h,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=r;}}getPosition(){return [this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ji(e,t){return [-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Vi(t){const i=e.bi(1323123451230),s=[];for(let r=0;r<t;++r){const t=2*i()-1,r=2*i()-1,o=2*i()-1;s.push(e.bh(t,r,o));}return s}function Gi(t,i,s,r,o){const n=e.b0((o-s)/(r-s),0,1);return e.al(t,i,n)}class qi{constructor(e){this._movement=new Ni,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Ui,this._ppmScaleFactor=e;}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy();}updateOnRender(t,i){const s=t.transform;this._movement.update(s,this._ppmScaleFactor);const r=s.starsProjMatrix,o=e.bd([]);e.be(o,o,e.au(90)-s._pitch),e.bf(o,o,-s.angle);const n=e.bg(new Float32Array(16),o),a=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),l=e.aP([],a),c=e.X([],l,n),h=Date.now()/1e3;return this._accumulatedTimeFromStart+=(h-this._prevTime)*i,this._prevTime=h,{projectionMatrix:r,modelviewMatrix:c}}}const Zi=e.a_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]),$i=(e,t)=>({u_matrix:e,u_depth_bias:t}),Hi=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t,u_opacity_multiplier:1}),Wi=(e,t,i,s,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:s,u_reset_depth:r}),Xi={building:t=>({u_matrix:new e.a5(t),u_normal_matrix:new e.a5(t),u_opacity:new e.a4(t),u_faux_facade_ao_intensity:new e.a4(t),u_camera_pos:new e.a6(t),u_tile_to_meter:new e.a4(t),u_facade_emissive_chance:new e.a4(t),u_flood_light_color:new e.a6(t),u_flood_light_intensity:new e.a4(t),u_front_cutoff_params:new e.a6(t)}),buildingBloom:t=>({u_matrix:new e.a5(t)}),buildingDepth:t=>({u_matrix:new e.a5(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.a5(t),u_depth_bias:new e.a4(t)}),elevatedStructures:t=>({u_matrix:new e.a5(t),u_ground_shadow_factor:new e.a6(t),u_opacity_multiplier:new e.a4(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.a5(t),u_camera_pos:new e.a6(t),u_depth_bias:new e.a4(t),u_height_scale:new e.a4(t),u_reset_depth:new e.a4(t)}),rasterParticle:t=>({u_matrix:new e.a5(t),u_normalize_matrix:new e.a5(t),u_globe_matrix:new e.a5(t),u_merc_matrix:new e.a5(t),u_grid_matrix:new e.aZ(t),u_tl_parent:new e.a3(t),u_scale_parent:new e.a4(t),u_fade_t:new e.a4(t),u_opacity:new e.a4(t),u_image0:new e.aX(t),u_image1:new e.aX(t),u_raster_elevation:new e.a4(t),u_zoom_transition:new e.a4(t),u_merc_center:new e.a3(t),u_cutoff_params:new e.aY(t)}),rasterParticleTexture:t=>({u_texture:new e.aX(t),u_opacity:new e.a4(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.aX(t),u_particle_texture_side_len:new e.a4(t),u_tile_offset:new e.a3(t),u_velocity:new e.aX(t),u_color_ramp:new e.aX(t),u_velocity_res:new e.a3(t),u_max_speed:new e.a4(t),u_uv_offset:new e.a3(t),u_data_scale:new e.a3(t),u_data_offset:new e.a4(t),u_particle_pos_scale:new e.a4(t),u_particle_pos_offset:new e.a3(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.aX(t),u_particle_texture_side_len:new e.a4(t),u_velocity:new e.aX(t),u_velocity_res:new e.a3(t),u_max_speed:new e.a4(t),u_speed_factor:new e.a4(t),u_reset_rate:new e.a4(t),u_rand_seed:new e.a4(t),u_uv_offset:new e.a3(t),u_data_scale:new e.a3(t),u_data_offset:new e.a4(t),u_particle_pos_scale:new e.a4(t),u_particle_pos_offset:new e.a3(t)}),snowParticle:t=>({u_modelview:new e.a5(t),u_projection:new e.a5(t),u_time:new e.a4(t),u_cam_pos:new e.a6(t),u_velocityConeAperture:new e.a4(t),u_velocity:new e.a4(t),u_horizontalOscillationRadius:new e.a4(t),u_horizontalOscillationRate:new e.a4(t),u_boxSize:new e.a4(t),u_billboardSize:new e.a4(t),u_simpleShapeParameters:new e.a3(t),u_screenSize:new e.a3(t),u_thinningCenterPos:new e.a3(t),u_thinningShape:new e.a6(t),u_thinningAffectedRatio:new e.a4(t),u_thinningParticleOffset:new e.a4(t),u_particleColor:new e.aY(t),u_direction:new e.a6(t)}),rainParticle:t=>({u_modelview:new e.a5(t),u_projection:new e.a5(t),u_time:new e.a4(t),u_cam_pos:new e.a6(t),u_texScreen:new e.aX(t),u_velocityConeAperture:new e.a4(t),u_velocity:new e.a4(t),u_boxSize:new e.a4(t),u_rainDropletSize:new e.a3(t),u_distortionStrength:new e.a4(t),u_rainDirection:new e.a6(t),u_color:new e.aY(t),u_screenSize:new e.a3(t),u_thinningCenterPos:new e.a3(t),u_thinningShape:new e.a6(t),u_thinningAffectedRatio:new e.a4(t),u_thinningParticleOffset:new e.a4(t),u_shapeDirectionalPower:new e.a4(t),u_shapeNormalPower:new e.a4(t),u_mode:new e.a4(t)}),vignette:t=>({u_vignetteShape:new e.a6(t),u_vignetteColor:new e.aY(t)})};function Ki(t,i){const s=1<<t.canonical.z,r=(i.x*s-t.canonical.x-t.wrap*s)*e.a2,o=(i.y*s-t.canonical.y)*e.a2,n=e.bm(i.z,i.y);return e.bh(r,o,n)}function Yi(e){let t=0;for(const i of e)t|=i.frcMask;return t}class Qi{constructor(e=[]){this.tiles=e;}getTile(e){for(const t of this.tiles)if(t.tileId.z===e.z&&t.tileId.x===e.x&&t.tileId.y===e.y)return t;return null}getTileOrParent(e){for(let t=e.z;t>0;--t){const i=Math.floor(e.x/(1<<e.z-t)),s=Math.floor(e.y/(1<<e.z-t));for(const e of this.tiles)if(e.tileId.z===t&&e.tileId.x===i&&e.tileId.y===s&&0!==e.frcMask)return e}return null}getFullCoverageMask(t){let i=null,s=0;for(let e=t.z;e>0;--e){const r=Math.floor(t.x/(1<<t.z-e)),o=Math.floor(t.y/(1<<t.z-e));for(const t of this.tiles)if(t.tileId.z===e&&t.tileId.x===r&&t.tileId.y===o){i=t,s=e;break}if(i)break}if(!i||0===i.frcMask)return null;const r=1<<t.z-s,o=e.a2/r,n=t.x%r*o,a=t.y%r*o,l=n+o,c=a+o;let h=0;for(const e of i.polygons)0!==e.frcMask&&(e.hasGeometry()?0===e.rings.length||t.z<=s||Ji(e.rings,n,a,l,c)&&(h|=e.frcMask):h|=e.frcMask);return 0!==h?h:null}equals(e){if(this.tiles.length!==e.length)return !1;for(let t=0;t<this.tiles.length;++t){const i=this.tiles[t],s=e[t];if(i.tileId.z!==s.tileId.z||i.tileId.x!==s.tileId.x||i.tileId.y!==s.tileId.y||i.frcMask!==s.frcMask||i.polygons.length!==s.polygons.length)return !1}return !0}empty(){return 0===this.tiles.length}}function Ji(e,t,i,s,r){const o=[0,0,0,0],n=[t,s,s,t],a=[i,i,r,r];for(const l of e){const e=l.length;if(!(e<2))for(let c=0,h=e-1;c<e;h=c++){const e=l[h].x,d=l[h].y,u=l[c].x,p=l[c].y;for(let t=0;t<4;++t)d>a[t]!=p>a[t]&&n[t]<e+(u-e)*(a[t]-d)/(p-d)&&o[t]++;let f=0,m=0;if(e<t?f|=1:e>s&&(f|=2),d<i?f|=4:d>r&&(f|=8),u<t?m|=1:u>s&&(m|=2),p<i?m|=4:p>r&&(m|=8),!(f&m)){if(0===f||0===m)return !1;if(es(e,d,u,p,t,i,s,r))return !1}}}for(let e=0;e<4;++e)if(!(1&o[e]))return !1;return !0}function es(e,t,i,s,r,o,n,a){const l=(e,t,i,s,r,o,n,a)=>{const l=(i-e)*(o-t)-(s-t)*(r-e),c=(i-e)*(a-t)-(s-t)*(n-e);if(l>0&&c>0||l<0&&c<0)return !1;const h=(n-r)*(t-o)-(a-o)*(e-r),d=(n-r)*(s-o)-(a-o)*(i-r);return !(h>0&&d>0||h<0&&d<0)};return !!(l(e,t,i,s,r,o,n,o)||l(e,t,i,s,n,o,n,a)||l(e,t,i,s,r,a,n,a)||l(e,t,i,s,r,o,r,a))}class ts{constructor(){this._tileCoverages=[],this._snapshot=new Qi;}clear(){this._tileCoverages=[];}addTileCoverage(e,t){this._tileCoverages.push({tileId:e,polygons:t,frcMask:Yi(t)});}empty(){return 0===this._tileCoverages.length}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;const e=this._tileCoverages.map(e=>({tileId:e.tileId,polygons:e.polygons,frcMask:e.frcMask}));return this._snapshot=new Qi(e),this._snapshot}}function is(e,t){const i={};if(!t)return i;for(const s of e){const e=s.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){s.layers=e,s.stateDependentLayerIds&&(s.stateDependentLayers=s.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0])),s.updateExpressions&&s.updateExpressions(e);for(const t of e)i[t.fqid]=s;}}return i}const ss=32,rs=33,os=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,s=0,r=0,o=0,n=0,a=0;for(1&t?r=o=n=ss:i=s=a=ss;(t>>=1)>1;){const e=i+r>>1,l=s+o>>1;1&t?(r=i,o=s,i=n,s=a):(i=r,s=o,r=n,o=a),n=e,a=l;}const l=4*e;os[l+0]=i,os[l+1]=s,os[l+2]=r,os[l+3]=o;}const ns=new Uint16Array(2178),as=new Uint8Array(1089),ls=new Uint16Array(1089);function cs(e){return 0===e?-.03125:32===e?.03125:0}var hs=e.a_([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);const ds=(()=>({type:2,extent:e.a2,loadGeometry:()=>[[new e.P(0,0),new e.P(e.a2+1,0),new e.P(e.a2+1,e.a2+1),new e.P(0,e.a2+1),new e.P(0,0)]]}))();let us,ps=0;class fs{constructor(t,i,s,r,o,n){this.tileID=t,this.uid=e.av(),this.uses=0,this.tileSize=i,this.tileZoom=s,this.dashIdealZ=t.overscaledZ,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=n,this._hasAppearances=null;}registerFadeDuration(t){const i=t+this.timeAdded;i<e.e.now()||void 0!==this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i);}wasRequested(){return "errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.bp(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,i,s){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=is(t.buckets,i.style),t.frcCoveragePolygons&&t.frcCoveragePolygons.length>0&&(this.frcCoveragePolygons=t.frcCoveragePolygons),this.hasDeferredRoadStructure=!!t.hasDeferredRoadStructure,void 0!==t.parsedElevationFeatures&&(this.parsedElevationFeatures=t.parsedElevationFeatures,this.parsedElevationGeneration=++ps),this.hasDeferredElevationFeatures=!!t.hasDeferredElevationFeatures,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!t.hasTunnelGeometry;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.bu){if(this.hasSymbolBuckets=!0,!s)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.bu&&i.hasRTLText){this.hasRTLText=!0,e.bN();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],s=i.style.getOwnLayer(e);if(!s)continue;const r=s.queryRadius(t)||0;this.queryPadding=Math.max(this.queryPadding,r);}t.imageAtlas&&(this.imageAtlas=i.style.imageManager.imageAtlasCache.getOrCache(t.imageAtlas)),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new e.bt;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets={...this.buckets,...is(e.buckets,t.style)},e.featureIndex&&(this.latestFeatureIndex=e.featureIndex));}getBucket(e){return this.buckets[e.fqid]}upload(t,i){for(const e in this.buckets){const s=this.buckets[e];if(s.uploadPending()){let e={},r=[],o={zoom:0,pitch:0,brightness:0,worldview:""};if(i){if(i.style){r=i.style.listImages();const t=s.layers[0],o=t.sourceLayer||"_geojsonTileLayer",n=i.style.getLayerSourceCache(t);n&&(e=n._state.getState(o,void 0));}o={zoom:i.transform.zoom||0,pitch:i.transform.pitch||0,brightness:i.style.getBrightness()||0,worldview:i.worldview||""};}s.upload(t,this.tileID.canonical,e,r,o);}}const s=t.gl,r=this.imageAtlas;r&&i&&(this.imageAtlasTexture=i.style.imageManager.imageAtlasCache.getTextureForAtlas(r,t,s.RGBA8),r.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,s.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,s.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&t){const s=t.style.getLut(i);this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i,s);}if(!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const s=t.style.getBrightness(),r=t.style.listImages(),o=r.length,n=t.style._changes.getUpdatedPaintProperties(),a=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>n.has(e.fqid))),l=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>e.hasTransition&&e.hasTransition())),c=this._firstPrepareComplete&&o!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t));const h=this._lastUpdatedBrightness!==s;this._lastAvailableImagesCount=o,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||s||this._hasAppearances||a||l||c)&&(!(this._hasAppearances||a||l||c)&&this._lastUpdatedBrightness&&s&&Math.abs(this._lastUpdatedBrightness-s)<.001||(this.updateBuckets(t,h,void 0,c||a||l,n,r),this._lastUpdatedBrightness=s));}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const i=this.buckets[t];i.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,i.evaluateQueryRenderedFeaturePadding()));}return e}queryRenderedFeatures(t,i,s,r,o,n,a){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return {};const l=this.evaluateQueryRenderedFeaturePadding(),c=function(t,i){const s=e.bL([],[.5*t.width,.5*-t.height,1]);return e.bM(s,s,[1,-1,0]),e.X(s,s,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(s)}(o,this.tileID);return this.latestFeatureIndex.query(t,{tilespaceGeometry:i,pixelPosMatrix:c,transform:r,availableImages:s,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:l,scope:a})}querySourceFeatures(t,i){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const r=s.loadVTLayers(),o=i?i.sourceLayer:"",n=r._geojsonTileLayer||r[o];if(!n)return;const a=e.bv(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,d={z:l,x:c,y:h};for(let i=0;i<n.length;i++){const r=n.feature(i);if(a.needGeometry){const t=e.bw(r,!0);if(!a.filter(new e.ai(this.tileID.overscaledZ,{worldview:this.worldview}),t,this.tileID.canonical))continue}else if(!a.filter(new e.ai(this.tileID.overscaledZ,{worldview:this.worldview}),r))continue;const u=s.getId(r,o),p=new e.bx(r,l,c,h,u);p.tile=d,t.push(p);}}loaded(){return "loaded"===this.state||"errored"===this.state}hasData(){return "loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return !!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.by(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"]);}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else {const s=this.expirationTime-i;s?this.expirationTime=e+Math.max(s,3e4):t=!0;}else t=!0;t?(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-Date.now(),Math.pow(2,31)-1)}refreshFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!e)return;const i=e.style.listImages();this.updateBuckets(e,!1,t,void 0,void 0,i);}hasAppearances(e){for(const t in this.buckets)if(e.style.hasLayer(t)&&this.buckets[t].layers.some(e=>e.appearances&&e.appearances.length>0))return !0;return !1}updateBuckets(t,i,s,r,o,n){if(!this.latestFeatureIndex)return;if(!t.style)return;const a=n||t.style.listImages(),l=t.style.getBrightness(),c=o||new Set;for(const o in this.buckets){if(!t.style.hasLayer(o))continue;const n=this.buckets[o],h=n.layers[0],d=h.sourceLayer||"_geojsonTileLayer",u=t.style.getLayerSourceCache(h),p=n.layers.some(e=>c.has(e.fqid)),f=(r||p)&&n instanceof e.bu?t.style.getOwnLayer(o):void 0;let m=s&&s[d]||{};u&&!s&&(m=u._state.getState(d,void 0));const _=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},g=Object.keys(m).length>0&&!i;n.hasAppearances=n.layers.some(e=>e.appearances&&e.appearances.length>0);const y=g?n.stateDependentLayers:n.layers;if(g&&0!==n.stateDependentLayers.length||i||p||r){const s=this.latestFeatureIndex.loadVTLayers()[d];if(n.update(m,s,a,_,y,i,l,this.tileID.canonical),(r||p)&&(!i||i&&n instanceof e.bu&&(!n.text.uboBinder||n.text.uboBinder.isLightConstant||!n.icon.uboBinder||n.icon.uboBinder.isLightConstant))&&n instanceof e.bu&&f&&"symbol"===f.type){const e=n;e.text&&e.text.uboBinder&&e.text.uboBinder.updateDynamicExpressions(f,s,this.tileID.canonical,a,m,l),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.updateDynamicExpressions(f,s,this.tileID.canonical,a,m,l);}if(n instanceof e.bu){const e=n,i=t.context;e.text&&e.text.uboBinder&&e.text.uboBinder.upload(i),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.upload(i);}}if(g&&0!==n.stateDependentLayers.length||i||n.hasAppearances){const i={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview},s=n.updateAppearances(this.tileID.canonical,m,a,i,t.imageManager,g&&0!==n.stateDependentLayers.length);if(s&&s.hasUboChanges){const i=t.context;n instanceof e.bu&&n.text&&n.text.uboBinder&&n.text.uboBinder.upload(i),n instanceof e.bu&&n.icon&&n.icon.uboBinder&&n.icon.uboBinder.upload(i);}}(n instanceof e.bz||n instanceof e.bA)&&t._terrain&&t._terrain.enabled&&u&&n.uploadPending()&&t._terrain._clearRenderCacheForTile(u.id,this.tileID);const v=t&&t.style&&t.style.getOwnLayer(o);v&&(this.queryPadding=Math.max(this.queryPadding,v.queryRadius(n)||0));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.e.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0;}setHoldDuration(t){this.symbolFadeHoldUntil=e.e.now()+t;}setTexture(t,i){const s=i.context,r=s.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t):(this.texture=new e.T(s,t,r.RGBA8,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));}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}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,i){if(!i||"mercator"===i.name||this._tileDebugBuffer)return;const s=e.bB(ds,this.tileID.canonical,this.tileTransform)[0],r=new e.bC,o=new e.bD;for(let e=0;e<s.length;e++){const{x:t,y:i}=s[e];r.emplaceBack(t,i),o.emplaceBack(e);}o.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(o),this._tileDebugBuffer=t.createVertexBuffer(r,e.bE.members),this._tileDebugSegments=e.ac.simpleSegment(0,0,r.length,o.length);}_makeTileBoundsBuffers(t,i){if(this._tileBoundsBuffer||!i||"mercator"===i.name)return;const s=e.bB(ds,this.tileID.canonical,this.tileTransform)[0];let r,o;if(this.isRaster){const t=function(t,i){const s=e.bp(t,i),r=Math.pow(2,t.z);for(let o=0;o<rs;o++)for(let n=0;n<rs;n++){const a=e.bq((t.x+(n+cs(n))/ss)/r),l=e.br((t.y+(o+cs(o))/ss)/r),c=i.project(a,l),h=o*rs+n;ns[2*h+0]=Math.round((c.x*s.scale-s.x)*e.a2),ns[2*h+1]=Math.round((c.y*s.scale-s.y)*e.a2);}as.fill(0),ls.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=os[t+0],s=os[t+1],r=os[t+2],o=os[t+3],n=i+r>>1,a=s+o>>1,l=n+a-s,c=a+i-n,h=s*rs+i,d=o*rs+r,u=a*rs+n,p=Math.hypot((ns[2*h+0]+ns[2*d+0])/2-ns[2*u+0],(ns[2*h+1]+ns[2*d+1])/2-ns[2*u+1])>=16;as[u]=as[u]||(p?1:0),e<1022&&(as[u]=as[u]||as[(s+c>>1)*rs+(i+l>>1)]||as[(o+c>>1)*rs+(r+l>>1)]);}const o=new e.bs,n=new e.ad;let a=0;function l(t,i){const s=i*rs+t;return 0===ls[s]&&(o.emplaceBack(ns[2*s+0],ns[2*s+1],t*e.a2/ss,i*e.a2/ss),ls[s]=++a),ls[s]-1}function c(e,t,i,s,r,o){const a=e+i>>1,h=t+s>>1;if(Math.abs(e-r)+Math.abs(t-o)>1&&as[h*rs+a])c(r,o,e,t,a,h),c(i,s,r,o,a,h);else {const a=l(e,t),c=l(i,s),h=l(r,o);n.emplaceBack(a,c,h);}}return c(0,0,ss,ss,ss,0),c(ss,ss,0,0,0,ss),{vertices:o,indices:n}}(this.tileID.canonical,i);r=t.vertices,o=t.indices;}else {r=new e.bs,o=new e.ad;for(const{x:e,y:t}of s)r.emplaceBack(e,t,0,0);const t=e.bF(r.int16.subarray(0,4*r.length),void 0,4);for(let e=0;e<t.length;e+=3)o.emplaceBack(t[e],t[e+1],t[e+2]);}this._tileBoundsBuffer=t.createVertexBuffer(r,hs.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(o),this._tileBoundsSegments=e.ac.simpleSegment(0,0,r.length,o.length);}_makeGlobeTileDebugBuffers(t,i){const s=i.projection;if(!s||"globe"!==s.name||i.freezeTileCoverage)return;const r=this.tileID.canonical,o=e.V(r,i),n=e.b4(o),a=e.S(i.zoom);let l;a>0&&(l=e.aO(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,n,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,n,l,a);}_globePoint(t,i,s,r,o,n,a){let l=e.bG(t,i,s);if(n){const o=1<<s.z,c=e.a7(r.center.lng),h=e.a8(r.center.lat),d=(s.x+.5)/o-c;let u=0;d>.5?u=-1:d<-.5&&(u=1);let p=(t/e.a2+s.x)/o+u,f=(i/e.a2+s.y)/o;p=(p-c)*r._pixelsPerMercatorPixel+c,f=(f-h)*r._pixelsPerMercatorPixel+h;const m=[p*r.worldSize,f*r.worldSize,0];e.bH(m,m,n),l=e.bI(l,m,a);}return e.bH(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,s,r,o,n){const a=new e.bC,l=new e.bD,c=new e.bJ,h=(e,t,h,d,u)=>{const p=(h-e)/(u-1),f=(d-t)/(u-1),m=a.length;for(let h=0;h<u;h++){const d=e+h*p,u=t+h*f;a.emplaceBack(d,u);const _=this._globePoint(d,u,i,s,r,o,n);c.emplaceBack(_[0],_[1],_[2]),l.emplaceBack(m+h);}},d=e.a2;h(0,0,d,0,16),h(d,0,d,d,16),h(d,d,0,d,16),h(0,d,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(a,e.bE.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(c,e.bK.members),this._tileDebugSegments=e.ac.simpleSegment(0,0,a.length,l.length);}_makeGlobeTileDebugTextBuffer(t,i,s,r,o,n){const a=e.a2/4,l=new e.bC,c=new e.ad,h=new e.bJ,d=25;c.reserve(32),l.reserve(d),h.reserve(d);const u=(e,t)=>d*e+t;for(let e=0;e<d;e++){const t=e*a;for(let e=0;e<d;e++){const c=e*a;l.emplaceBack(c,t);const d=this._globePoint(c,t,i,s,r,o,n);h.emplaceBack(d[0],d[1],d[2]);}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=u(e,t),s=u(e,t+1),r=u(e+1,t),o=u(e+1,t+1);c.emplaceBack(i,s,r),c.emplaceBack(r,s,o);}this._tileDebugTextIndexBuffer=t.createIndexBuffer(c),this._tileDebugTextBuffer=t.createVertexBuffer(l,e.bE.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(h,e.bK.members),this._tileDebugTextSegments=e.ac.simpleSegment(0,0,d,32);}destroy(t=!0){for(const e in this.buckets)this.buckets[e].destroy(t);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof e.T&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded";}}class ms{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 s=e.wrapped().key;void 0===this.data[s]&&(this.data[s]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r);},i)),this.data[s].push(r),this.order.push(s),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,s=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][s];return this.data[i].splice(s,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 s of this.data[i])e(s.value)||t.push(s);for(const e of t)this.remove(e.value.tileID,e);}}class _s{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null);}updateState(e,t,i){const s=String(t);if(this.stateChanges[e]=this.stateChanges[e]||Object.create(null),this.stateChanges[e][s]=this.stateChanges[e][s]||Object.create(null),Object.assign(this.stateChanges[e][s],i),null===this.deletedStates[e]){this.deletedStates[e]=Object.create(null);for(const t in this.state[e])t!==s&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][s]){this.deletedStates[e][s]=Object.create(null);for(const t in this.state[e][s])i[t]||(this.deletedStates[e][s][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][s]&&null===this.deletedStates[e][s][t]&&delete this.deletedStates[e][s][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const s=String(t);if(this.deletedStates[e]=this.deletedStates[e]||Object.create(null),i&&void 0!==t)null!==this.deletedStates[e][s]&&(this.deletedStates[e][s]=this.deletedStates[e][s]||Object.create(null),this.deletedStates[e][s][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][s])for(i in this.deletedStates[e][s]=Object.create(null),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=this.state[e]||Object.create(null),s=this.stateChanges[e]||Object.create(null),r=this.deletedStates[e];if(null===r)return Object.create(null);if(void 0!==t){const e=String(t),o=Object.assign(Object.create(null),i[e],s[e]);if(r){const e=r[t];if(null===e)return Object.create(null);for(const t in e)delete o[t];}return o}const o=Object.assign(Object.create(null),i,s);if(r)for(const e in r)delete o[e];return o}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(e,t){const i=Object.create(null);for(const e in this.stateChanges){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]=Object.create(null)),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);if(null===this.deletedStates[e])for(const i in this.state[e])t[i]=Object.create(null),this.state[e][i]=Object.create(null);else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]=Object.create(null);else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||Object.create(null),Object.assign(i[e],t);}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),0!==Object.keys(i).length)for(const s in e)e[s].refreshFeatureState(t,i);}}class gs extends e.E{constructor(e,t,i){super(),this.id=e,this._renderSourceType=i,this._maxzoomOverride=null,this.setSource(t),this._tiles={},this._cache=new ms(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new _s,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}setSource(e){e.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));}),e.on("error",()=>{this._sourceErrored=!0;}),this._source=e;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles)if(!this._tiles[e].loaded())return !1;return !0}getSource(){return this._source}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);}setMaxzoomOverride(e){this._maxzoomOverride=e;}_loadTile(e,t){return e.renderSourceType=this._renderSourceType,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(ys).map(e=>e.key)}getRenderableIds(t,i){const s=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&s.push(this._tiles[e]);return t?s.sort((t,i)=>{const s=t.tileID,r=i.tileID,o=new e.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle),n=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return s.overscaledZ-r.overscaledZ||n.y-o.y||n.x-o.x}).map(e=>e.tileID.key):s.map(e=>e.tileID).sort(ys).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,s,r,o){if(r){if(t.state="errored",e.bO(r)){if(this._source.fire(new e.h("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else this._source.fire(new e.f(r,{tile:t}));return}t.timeAdded=e.e.now(),"expired"===s&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let n=new Headers;o&&o.headers&&(n=o.headers),this._source.fire(new e.h("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:n}));}_hasTunnelGeometry(){for(const e in this._tiles){const t=this._tiles[e];if(t&&t.hasTunnelGeometry)return !0}return !1}_backfillDEM(e){const t=this.getRenderableIds();for(let s=0;s<t.length;s++){const r=t[s];if(e.neighboringTiles&&e.neighboringTiles[r]){const t=this.getTileByID(r);i(e,t),i(t,e);}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const s=t.tileID.canonical.y-e.tileID.canonical.y,r=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===s||Math.abs(s)>1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,s),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,s){for(const r in this._tiles){let o=this._tiles[r];if(s[r]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let n=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(n=e);}let a=n;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){s[n.key]=n;const e=this._tiles[n.key];e&&(e.dashIdealZ=a.overscaledZ);break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),s=this._getLoadedTile(t);if(s)return s}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,s=Math.ceil(e.height/t)+1,r=Math.floor(i*s*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(n);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const s=this._tiles[i];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),e[s.tileID.key]=s;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(t,i,s,r,o){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!s)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const n="batched-model"===this._source.type;let a,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t);}const h=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.bP(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!s,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:n}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.bP(1,0,1,0,0)),a.push(new e.bP(1,0,1,1,0)),a.push(new e.bP(1,0,1,0,1)),a.push(new e.bP(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!s,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:n}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t));}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!s}),c=Math.min(e,l);if(n){const e=t.extendTileCover(a,c);for(const t of e)a.push(t);}else if(o){const e=this.transform.getFrustum(c),i=t.extendTileCoverToNearPlane(a,e,c);for(const e of i)a.push(e);if(c>=18&&this._hasTunnelGeometry()){const i=t.extendTileCoverForTunnels(a,e,c,20);for(const e of i)a.push(e);}}else if(this.castsShadows&&r){const e=t.extendTileCover(a,c,r,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}for(const e in this._tiles){const t=this._tiles[e];t.dashIdealZ=t.tileID.overscaledZ;}const d=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},s=e.e.now(),r=Object.keys(d);for(const e of r){const r=d[e],o=this._tiles[e];if(!o||void 0!==o.fadeEndTime&&o.fadeEndTime<=s)continue;const n=this.findLoadedParent(r,Math.max(r.overscaledZ-gs.maxOverzooming,this._source.minzoom));n&&(this._addTile(n.tileID),t[n.tileID.key]=n.tileID),i[e]=r;}const o=a.at(-1).overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(d[e]||!t.hasData())continue;let s=t.tileID;for(;s.overscaledZ>o;){s=s.scaledTo(s.overscaledZ-1);const r=this._tiles[s.key];if(r&&r.hasData()&&i[s.key]){d[e]=t.tileID;break}}}for(const e in t)d[e]||(this._coveredTiles[e]=!0,d[e]=t[e]);}for(const e in d)this._tiles[e].clearFadeHold();const u=e.bQ(this._tiles,d);for(const e of u){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._renderSourceType===e.bR.Symbol&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},s=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,o=Math.max(r-gs.maxOverzooming,this._source.minzoom),n=Math.max(r+gs.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||s<this._source.maxzoom&&(a[i.key]=i);}this._retainLoadedChildren(a,s,n,t);for(const s of e){let e=this._tiles[s.key];if(e.hasData())continue;if(s.canonical.z>=this._source.maxzoom){const e=s.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e,i.dashIdealZ=s.overscaledZ;continue}}else {const e=s.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let n=s.overscaledZ-1;n>=o;--n){const o=s.scaledTo(n);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,e.dashIdealZ=s.overscaledZ,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,s=this._tiles[e].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){i=this._loadedParentTiles[s.key];break}t.push(s.key);const e=s.scaledTo(s.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;s=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const s=Boolean(i);if(!s){const e=this.map?this.map.painter:null,s=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?function(e,t,i,s,r){if(!us)throw new Error("Raster-array module is not loaded.");return us(e,t,i,s,r)}(t,s,this.transform.tileZoom,e,this._isRaster):new fs(t,s,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i.uses++,this._tiles[t.key]=i,s||this._source.fire(new e.h("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e];},i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(t,i,s){const r=[],o=this.transform;if(!o)return r;const n="globe"===o.projection.name,a=e.a7(o.center.lng),l=o.getFreeCameraOptions().position||new e.bS(0,0,0);for(const c in this._tiles){const h=this._tiles[c];if(s&&h.clearQueryDebugViz(),h.holdingForFade())continue;let d;if(n){const t=h.tileID.canonical;if(0===t.z){const i=[Math.abs(e.b0(a,...vs(t,-1))-a),Math.abs(e.b0(a,...vs(t,1))-a)];d=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.b0(a,...vs(t,-1))-a),Math.abs(e.b0(a,...vs(t,0))-a),Math.abs(e.b0(a,...vs(t,1))-a)];d=[i.indexOf(Math.min(...i))-1];}}else d=[0];for(const e of d){const s=t.containsTile(h,o,i,e,l);s&&r.push(s);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){if(!this.transform)return [];const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),s="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=s?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){if(!this.transform)return e.slice();const t=e.slice(),i=this.transform._camera.position,s=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<<e.canonical.z);r[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*s[0]+((e.canonical.y+.5)*t-i[1])*s[1]-i[2]*s[2];}return t.sort((e,t)=>r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return !0;if(this._supportsFading){const t=e.e.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return !0}}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const s=this._tiles[e];s&&s.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const s=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,n=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)s.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(s.values());e.bT(a,(e,t)=>{const i=new fs(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);});},i);}}function ys(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||s-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function vs(e,t){const i=1<<e.z;return [e.x/i+t,(e.x+1)/i+t]}function bs(e,t){if(e.z<=t.z){const i=t.z-e.z;return t.x>>i===e.x&&t.y>>i===e.y}const i=e.z-t.z;return e.x>>i===t.x&&e.y>>i===t.y}function xs(e,t){return e.sourceFQID!==t.sourceFQID?e.sourceFQID<t.sourceFQID?-1:1:e.tileId.z!==t.tileId.z?e.tileId.z-t.tileId.z:e.tileId.x!==t.tileId.x?e.tileId.x-t.tileId.x:e.tileId.y-t.tileId.y}gs.maxOverzooming=10,gs.maxUnderzooming=3;class ws{constructor(e=[]){this.tiles=e;}getTilesIntersecting(e){const t=[];for(const i of this.tiles)bs(i.tileId,e)&&t.push(i);return t}equals(e){if(this.tiles.length!==e.length)return !1;for(let t=0;t<this.tiles.length;++t){const i=this.tiles[t],s=e[t];if(i.sourceFQID!==s.sourceFQID||i.tileId.z!==s.tileId.z||i.tileId.x!==s.tileId.x||i.tileId.y!==s.tileId.y||i.generation!==s.generation)return !1}return !0}empty(){return 0===this.tiles.length}}class Ts{constructor(){this._tiles=[],this._snapshot=new ws,this._snapshotChanged=!1;}clear(){this._tiles.length=0;}consumeSnapshotChanged(){const e=this._snapshotChanged;return this._snapshotChanged=!1,e}addTileElevation(e,t,i,s){this._tiles.push({sourceFQID:e,tileId:t,features:i,generation:s});}updateSnapshotIfNeeded(){return this._tiles.sort(xs),this._snapshot.equals(this._tiles)||(this._snapshot=new ws(this._tiles.slice()),this._snapshotChanged=!0),this._snapshot}}function Ss(e,t){const i=[];for(const s of e.getTilesIntersecting(t))i.push(`${s.tileId.z}/${s.tileId.x}/${s.tileId.y}:${s.generation}`);return i.sort(),i.join("|")}function Cs(t,i){const s=e.bW(t);return s===i||!s&&!i}function Es(e,t){return e._mergedOtherSourceCaches[t]||e._mergedSymbolSourceCaches[t]||e._mergedHdRoadElevationSourceCaches[t]}function Is(e){const t=e.sourceLayer;return !!t&&t.startsWith("hd_road_")}function Ds(e){return !!e.layout&&("line"===e.type&&"hd-road-markup"===e.layout.get("line-elevation-reference")||"circle"===e.type&&"hd-road-markup"===e.layout.get("circle-elevation-reference")||"symbol"===e.type&&"hd-road-markup"===e.layout.get("symbol-elevation-reference")||"fill"===e.type&&"hd-road-markup"===e.layout.get("fill-elevation-reference"))}function Ps(t){const i=new Set;for(const s in t._mergedLayers){const r=t._mergedLayers[s];Ds(r)&&i.add(e.m(r.source,r.scope));}return i}function Ls(t){const i=Ps(t),s=new Set;for(const r in t._mergedLayers){const o=t._mergedLayers[r];if(!o.source||!Is(o))continue;const n=e.m(o.source,o.scope);i.has(n)||s.add(n);}return s}function Rs(e){const t=Ps(e);if(0===t.size)return !1;const i=As(e);for(const e of t)for(const t of i)if(e!==t)return !0;return !1}function As(t){const i=new Set;for(const s in t._mergedLayers){const r=t._mergedLayers[s];r.source&&Is(r)&&i.add(e.m(r.source,r.scope));}return i}function Ms(e,t,i){const s=Ps(e);if(0===s.size)return;if(!i){const t=As(e);for(const e of t)s.delete(e);}if(0===s.size)return;const r=[e._mergedOtherSourceCaches,e._mergedSymbolSourceCaches];for(const e of r)for(const i in e){if(!s.has(i))continue;const r=e[i];for(const e in r._tiles){const i=r._tiles[e];i&&(t&&!t(i)||(i.hasDeferredElevationFeatures=!1,r._reloadTile(+e,"reloading")));}}}class Fs{constructor(){this.elevationSourceCaches={},this.manager=new Ts,this._needsCrossSourceElevation=!1,this._ingestFQIDs=new Set,this._terrainActiveLast=void 0;}}function Os(e){e.map&&e.map.painter&&(e.map.painter.elevationCoverageSnapshot=null,e.map.painter.elevationProvidersReady=void 0);}function Bs(e){e._crossSourceElevationActive=!1,function(e){const t=e._hdElevation,i=!!(e.map&&e.map.painter&&e.map.painter.elevationCoverageSnapshot);return t?!t._needsCrossSourceElevation&&0===t._ingestFQIDs.size&&0===t.manager._tiles.length&&!i:!i}(e)||(Os(e),e._hdElevation&&(e._hdElevation._needsCrossSourceElevation=!1,e._hdElevation._ingestFQIDs.clear(),e._hdElevation.manager.clear(),e._hdElevation._terrainActiveLast=void 0));}function ks(t,i,s){const r=e.m(s.id,t.scope);if(i.elevationSourceCaches[r])return;const o=`hd-road-elevation:${s.id}`,n=e.m(o,t.scope),a=t._sourceCaches[o]=new gs(n,s,e.bR.HdRoadElevation);i.elevationSourceCaches[r]=a,a.onAdd(t.map);const l=t._otherSourceCaches[s.id];l&&l._sourceLoaded&&(a._sourceLoaded=!0);}function zs(e,t){if(Gt(e,e.map&&e.map.transform))return t.manager.clear(),void(e.map.painter&&(e.map.painter.elevationCoverageSnapshot=null));if(!t._needsCrossSourceElevation)return void Os(e);for(const i of t._ingestFQIDs){const t=Es(e,i);t&&(t.used=!0);}t.manager.clear();let i=!0;for(const s of t._ingestFQIDs){const r=Es(e,s);if(!r)continue;const o=r._tiles;for(const e in o){const r=o[e];if(!r||!r.loaded())continue;const n=r.parsedElevationFeatures;void 0!==n?t.manager.addTileElevation(s,r.tileID.canonical,n,r.parsedElevationGeneration):i=!1;}}const s=t.manager._snapshot,r=t.manager.updateSnapshotIfNeeded();e.map.painter&&(e.map.painter.elevationCoverageSnapshot=r.empty()?null:r);const o=i&&function(e,t){for(const i of t){const t=Es(e,i);if(!t)return !1;if(!t._sourceLoaded)return !1;for(const e in t._tiles){const i=t._tiles[e];if(i&&("loading"===i.state||"reloading"===i.state))return !1}}return !0}(e,Ls(e));e.map.painter&&(e.map.painter.elevationProvidersReady=o);const n=t.manager.consumeSnapshotChanged();(n||o)&&Ms(e,e=>{return !!e.hasDeferredElevationFeatures||n&&(t=r,Ss(s,i=e.tileID.canonical)!==Ss(t,i));var t,i;});}const Us=e=>({u_matrix:e});function Ns(t,i){const s=t.context.gl;return new e._({func:s.EQUAL,mask:255},t._tileClippingMaskIDs[i.key]||0,0,s.KEEP,s.KEEP,s.KEEP)}function js(t,i){const s=t.context.gl;return new e._({func:s.EQUAL,mask:255},255&~(t._tileClippingMaskIDs[i.key]||0),0,s.KEEP,s.KEEP,s.KEEP)}function Vs(t,i){if(!t.frcCoverageSnapshot||!t.frcCoverageRenderer)return null;const s=t.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!s||0===s.frcMask)return null;const r=t.frcCoverageRenderer.getBuffers(s.tileId);if(!r)return null;const o=new e.bX(s.tileId.z,s.tileId.x,s.tileId.y),n=new e.bY(i.wrap,o);return {buffers:r,projMatrix:t.transform.calculateProjMatrix(n),coverageTile:s}}function Gs(t,i,s){if(!t.frcCoverageSnapshot)return;const r=t.context,o=r.gl,n=t.getOrCreateProgram("clippingMask");r.setColorMode(e.a1.disabled),r.setDepthMode(e.Z.disabled);for(const r of i){const i=Vs(t,r);if(!i)continue;const a=i.buffers.frcLevelSegments[s];a&&n.draw(t,o.TRIANGLES,e.Z.disabled,new e._({func:o.EQUAL,mask:255},t._tileClippingMaskIDs[r.key]||0,255,o.KEEP,o.KEEP,o.INVERT),e.a1.disabled,e.$.disabled,Us(i.projMatrix),`$frc_coverage_${s}`,i.buffers.vertexBuffer,i.buffers.indexBuffer,a);}}function qs(t,i,s){if(!t.frcCoverageSnapshot)return;const r=t.context,o=r.gl,n=t.getOrCreateProgram("clippingMask");r.setColorMode(e.a1.disabled),r.setDepthMode(e.Z.disabled);for(const r of i){const i=Vs(t,r);if(!i)continue;const a=i.buffers.frcLevelSegments[s];a&&n.draw(t,o.TRIANGLES,e.Z.disabled,new e._({func:o.EQUAL,mask:255},255&~(t._tileClippingMaskIDs[r.key]||0),255,o.KEEP,o.KEEP,o.INVERT),e.a1.disabled,e.$.disabled,Us(i.projMatrix),`$frc_coverage_restore_${s}`,i.buffers.vertexBuffer,i.buffers.indexBuffer,a);}}function Zs(e,t,i,s,r){if(0===t.length)return;let o=0;for(const e of t)o|=e.frcMask;const n=t.map(e=>e.coord);for(let a=0;a<9;++a)if(o&1<<a){if(Gs(e,n,a),s)for(const i of t)i.frcMask&1<<a&&s(i,a,Ns(e,i.coord));if(i>0&&r)for(const i of t)i.frcMask&1<<a&&r(i,a,js(e,i.coord));qs(e,n,a);}}function $s(e){for(const t of e)if(t.rings.length>0&&t.rings[0].length>0)return !0;return !1}function Hs(e){const t=e.frcCoverageFadeRange;return !t||t[1]<=t[0]?0:1-Math.max(0,Math.min(1,(e.transform.zoom-t[0])/(t[1]-t[0])))}const Ws={loaded:!0,drawBuilding:function(t,i,s,r){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);const o=s.paint.get("building-ambient-occlusion-ground-intensity"),n=s.paint.get("building-ambient-occlusion-ground-radius"),a=s.paint.get("building-ambient-occlusion-ground-attenuation"),l=s.paint.get("building-opacity");if(l<=0)return;let c=o>0&&n>0,h=!0;const d=s.paint.get("building-vertical-scale");if(d<=0)return;t.shadowRenderer||(h=!1);const u=t.conflationActive&&t.style.isLayerClipped(s,i.getSource()),p=t.style.order.indexOf(s.fqid);if(function(e,t,i,s,r,o){for(const n of o){const o=t.getTile(n).getBucket(i);o&&(r&&o.updateReplacement(n,e.replacementSource,s),o.uploadUpdatedIndexBuffer(e.context));}}(t,i,s,p,u,r),function(e,t,i,s){for(const r of s){const s=t.getTile(r).getBucket(i);s&&s.needsEvaluation()&&s.uploadUpdatedColorBuffer(e.context);}}(t,i,s,r),s.resetLayerRenderingStats(t),t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0),"shadow"===t.renderPass&&t.shadowRenderer){const o=[],n=t.shadowRenderer.getShadowPassDepthMode();xi({painter:t,source:i,layer:s,coords:r,defines:o,blendMode:e.a1.disabled,depthMode:n,opacity:l,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}else if("translucent"===t.renderPass){let p=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];h&&(p=p.concat("RENDER_SHADOWS")),t.shadowRenderer&&t.shadowRenderer.useNormalOffset&&(p=p.concat("NORMAL_OFFSET"));const f=s.paint.get("building-facade-emissive-chance"),m=s.paint.get("building-ambient-occlusion-intensity"),_=s.paint.get("building-flood-light-intensity"),g="none"===s.paint.get("building-flood-light-color-use-theme").constantOr("default"),y=s.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:s.lut).toArray01().slice(0,3),v=s.paint.get("building-flood-light-ground-attenuation"),b=_>0,x=new e.Z(t.context.gl.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D);l<1&&xi({painter:t,source:i,layer:s,coords:r,defines:p,blendMode:e.a1.disabled,depthMode:x,opacity:l,verticalScale:d,facadeEmissiveChance:f,facadeAOIntensity:m,floodLightIntensity:_,floodLightColor:y,depthOnly:!0});const w=t.colorModeForRenderPass();xi({painter:t,source:i,layer:s,coords:r,defines:p,blendMode:w,depthMode:x,opacity:l,verticalScale:d,facadeEmissiveChance:f,facadeAOIntensity:m,floodLightIntensity:_,floodLightColor:y});const T=s.paint.get("building-front-cutoff");pi(t.transform.pitch,T,!!t.terrain),c&&wi(t,i,s,r,!0,l,o,n,_,y,a,u),b&&wi(t,i,s,r,!1,l,o,n,_,y,v,u);}else if("light-beam"===t.renderPass){const o=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],n=new e.Z(t.context.gl.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D);xi({painter:t,source:i,layer:s,coords:r,defines:o,blendMode:e.a1.alphaBlended,depthMode:n,opacity:l,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1),t.resetStencilClippingMasks();},BuildingTileBorderManager:class{constructor(){this.visibleTiles=[];}updateBorders(t,i){const s=[],r=[],o=t._getRenderableCoordinates(!1,!0);for(const e of o){const o=t.getTile(e);if(!o.hasData())continue;const n=o.getBucket(i);n&&(n.isEmpty()||(s.push(e.key),r.push({bucket:n,tileID:e.canonical})));}let n=s.length!==this.visibleTiles.length;if(!n){s.sort();for(let e=0;e<s.length;e++)if(s[e]!==this.visibleTiles[e]){n=!0;break}}if(!n)return;const a=new Set;this.visibleTiles=s,r.sort((e,t)=>e.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,s=new Array,r=t.bucket;for(const t of r.featuresOnBorder)r.footprints[t.footprintIndex].hiddenFlags&e.aR||(a.has(t.featureId)?s.push(t.footprintIndex):(a.add(t.featureId),i.push(t.footprintIndex)));r.updateFootprintHiddenFlags(i,e.aS,!1),r.updateFootprintHiddenFlags(s,e.aS,!0);}}},drawRasterParticle:function(t,i,s,r,o,n){"offscreen"===t.renderPass&&function(t,i,s,r){if(!r.length)return;const o=t.context,n=o.gl,a=i.getSource();if("raster-array"!==a.type)return;const l=Math.ceil(Math.sqrt(s.paint.get("raster-particle-count")));let c=s.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(t){const i=t*t,s=new Uint8Array(4*i),r=.9090909090909091;for(let t=0;t<i;t++){const i=r*(e.b8(2*t+0)+Si),o=r*(e.b8(2*t+1)+Si),n=255*i%1,a=255*o%1,l=n,c=o-a/255,h=a;s[4*t+0]=255*(i-n/255),s[4*t+1]=255*l,s[4*t+2]=255*c,s[4*t+3]=255*h;}return s}(l);c=s.particlePositionRGBAImage=new e.b({width:l,height:l},t);}let h=s.particleFramebuffer;h?h.width!==l&&(h.destroy(),h=s.particleFramebuffer=o.createFramebuffer(l,l,1,null)):h=s.particleFramebuffer=o.createFramebuffer(l,l,1,null);const d=[];for(const e of r){const t=i.getTile(e);if(!t)continue;const r=Mi(t,a,s);if(!r)continue;const n=[t.tileSize,t.tileSize];let h=s.tileFramebuffer;h||(h=s.tileFramebuffer=o.createFramebuffer(n[0],n[1],1,null));let u=t.rasterParticleState;u||(u=t.rasterParticleState=new Ri(o,e,n,c));const p=u.update(s.lastInvalidatedAt);u.particleTextureDimension!==l&&u.updateParticleTexture(e,c);const f=u.targetColorTexture;u.targetColorTexture=u.backgroundColorTexture,u.backgroundColorTexture=f;const m=u.particleTexture0;u.particleTexture0=u.particleTexture1,u.particleTexture1=m,d.push([e,r,u,p]);}if(0===d.length)return;const u=e.e.now(),p=s.previousDrawTimestamp?.001*(u-s.previousDrawTimestamp):.0167;if(s.previousDrawTimestamp=u,s.hasColorMap()){o.activeTexture.set(n.TEXTURE0+2);let t=s.colorRampTexture;t||(t=s.colorRampTexture=new e.T(o,s.colorRamp,n.RGBA8)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE);}o.bindFramebuffer.set(s.tileFramebuffer.framebuffer),function(t,i,s){const r=t.context,o=r.gl,n=i.tileFramebuffer;r.activeTexture.set(o.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=i.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of s){const[,,s,h]=c;n.colorAttachment0.set(s.targetColorTexture.texture),r.viewport.set([0,0,n.width,n.height]),r.clear({color:e.C.transparent}),h&&(s.backgroundColorTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),l.draw(t,o.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.alphaBlended,e.$.disabled,a,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments));}}(t,s,d),function(t,i,s,r){const o=t.context,n=o.gl,a=s.tileFramebuffer,l="globe"===t.transform.projection.name,c=s.paint.get("raster-particle-max-speed");for(const h of r){const[r,d,u]=h;o.activeTexture.set(n.TEXTURE0+0),d.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),a.colorAttachment0.set(u.targetColorTexture.texture);const p=t.getOrCreateProgram("rasterParticleDraw",{defines:d.defines,overrideFog:!1});o.activeTexture.set(n.TEXTURE0+1);const f=d.scalarData?[]:[0,1,2,3].map(t=>e.aB[t](r));f.push(r);const m=r.canonical.x,_=r.canonical.y;for(const o of f){const a=i.getTile(l?o.wrapped():o);if(!a)continue;const h=a.rasterParticleState;if(!h)continue;const u=o.canonical.x+(1<<o.canonical.z)*(o.wrap-r.wrap),f=o.canonical.y;h.particleTexture0.bind(n.NEAREST,n.CLAMP_TO_EDGE);const g=Ei(1,h.particleTexture0.size[0],[u-m,f-_],0,d.texture.size,2,c,d.textureOffset,d.scale,d.offset);p.draw(t,n.POINTS,e.Z.disabled,e._.disabled,e.a1.alphaBlended,e.$.disabled,g,s.id,h.particleIndexBuffer,void 0,h.particleSegment);}}}(t,i,s,d),o.bindFramebuffer.set(s.particleFramebuffer.framebuffer),function(t,i,s,r){const o=t.context,n=o.gl,a=i.paint.get("raster-particle-max-speed"),l=r*i.paint.get("raster-particle-speed-factor")*.15,c=function(e){return Math.pow(e,6)}(.01+1*i.paint.get("raster-particle-reset-rate-factor")),h=i.particleFramebuffer;o.viewport.set([0,0,h.width,h.height]);for(const r of s){const[,s,d]=r;o.activeTexture.set(n.TEXTURE0+0),s.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),o.activeTexture.set(n.TEXTURE0+1);const u=d.particleTexture0;u.bind(n.NEAREST,n.CLAMP_TO_EDGE);const p=Ii(1,u.size[0],0,s.texture.size,a,l,c,s.textureOffset,s.scale,s.offset);h.colorAttachment0.set(d.particleTexture1.texture),o.clear({color:e.C.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:s.defines}).draw(t,n.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.unblended,e.$.disabled,p,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments);}}(t,s,d,p);}(t,i,s,r),"translucent"===t.renderPass&&(function(t,i,s,r){const o=t.context,n=o.gl,a=i.getSource().tileSize,l=5*(1-e.am(e.b1,e.b1+1,t.transform.zoom))*a+s.paint.get("raster-particle-elevation"),c=!t.options.moving,h="globe"===t.transform.projection.name;if(!r.length)return;const[d,u]=t.stencilConfigForOverlap(r),p=[];h&&p.push("PROJECTION_GLOBE_VIEW");const f=t.stencilModeFor3D();for(const r of u){const a=r.toUnwrapped(),u=i.getTile(r);if(!u.rasterParticleState)continue;const m=u.rasterParticleState,_=100;u.registerFadeDuration(_);const g=i.findLoadedParent(r,0),y=Ai(u,g,i,t.transform,_);let v,b;t.terrain&&t.terrain.prepareDrawTile(),o.activeTexture.set(n.TEXTURE0),m.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),o.activeTexture.set(n.TEXTURE1),g&&g.rasterParticleState?(g.rasterParticleState.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),v=Math.pow(2,g.tileID.overscaledZ-u.tileID.overscaledZ),b=[u.tileID.canonical.x*v%1,u.tileID.canonical.y*v%1]):m.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const x=h?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(a,c),w=t.transform,T=Fi(w),S=e.b2(r.canonical),C=e.b3(S.getCenter().lat);let E,I,D,P,L;h?(E=Float32Array.from(e.b4(e.b5(r.canonical))),I=Float32Array.from(w.globeMatrix),D=Float32Array.from(e.b6(w)),P=[e.a7(w.center.lng),e.a8(w.center.lat)],L=Float32Array.from(e.b7(r.canonical,S,C,w.worldSize/w._pixelsPerMercatorPixel))):(E=new Float32Array(16),I=new Float32Array(9),D=new Float32Array(16),P=[0,0],L=new Float32Array(9));const R=Ci(x,E,I,D,L,b||[0,0],e.S(t.transform.zoom),P,T,v||1,y,l),A=t.isTileAffectedByFog(r),M=t.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:A});if(t.uploadCommonUniforms(o,M,a),h){const i=new e.Z(n.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D),r=0,o=t.globeSharedBuffers;if(o){const[a,l,c]=o.getGridBuffers(C,0!==r);M.draw(t,n.TRIANGLES,i,f,e.a1.alphaBlended,t.renderElevatedRasterBackface?e.$.frontCCW:e.$.backCCW,R,s.id,a,l,c);}}else {const i=t.depthModeForSublayer(0,e.Z.ReadOnly),o=d[r.overscaledZ],{tileBoundsBuffer:a,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=t.getTileBoundsBuffers(u);M.draw(t,n.TRIANGLES,i,o,e.a1.alphaBlended,e.$.disabled,R,s.id,a,l,c);}}t.resetStencilClippingMasks();}(t,i,s,r),t.style.map.triggerRepaint());},prepareRasterParticle:function(e,t,i){const s=t.getSource();if("raster-array"!==s.type||!s.loaded())return;const r=e.sourceLayer||s.rasterLayerIds&&s.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-particle-array-band")||s.getInitialBand(r);if(null==o)return;const n=t.getIds().map(e=>t.getTileByID(e));for(const t of n)t.updateNeeded(e.id,o)&&s.prepareTile(t,r,e.id,o);},Rain:class extends qi{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=Vi(this.particlesCount),s=new e.bk,r=new e.ad;let o=0;const n=e.bi(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=[2*n()-1,n(),n(),n()];s.emplaceBack(i[0],i[1],i[2],-1,-1,...a),s.emplaceBack(i[0],i[1],i[2],1,-1,...a),s.emplaceBack(i[0],i[1],i[2],1,1,...a),s.emplaceBack(i[0],i[1],i[2],-1,1,...a),r.emplaceBack(o+0,o+1,o+2),r.emplaceBack(o+0,o+2,o+3),o+=4;}this.particlesVx=i.createVertexBuffer(s,ki.members),this.particlesIdx=i.createIndexBuffer(r);}}getDrawParams(e){if(!e.style.rain)return null;const t=e.style.rain.state,i=structuredClone(this._params);i.intensity=t.density,i.timeFactor=t.intensity,i.color=structuredClone(t.color),i.screenThinning.intensity=t.centerThinning,i.dropletSizeX=t.dropletSize[0],i.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],i.distortionStrength=100*t.distortionStrength;const s=structuredClone(this._vignetteParams);return s.strength=1,s.color=structuredClone(t.vignetteColor),{params:i,vignetteParams:s,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(t){const i=this.getDrawParams(t);if(!i)return;const{params:s,revealParams:r,direction:o,vignetteParams:n}=i,a=t.transform.zoom;if(r.revealStart>a)return;const l=Gi(0,1,r.revealStart,r.revealStart+r.revealRange,a);if(!this.particlesVx||!this.particlesIdx)return;n.strength*=l;const c=this.updateOnRender(t,s.timeFactor),h=t.context,d=h.gl,u=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(h,{width:t.width,height:t.height,data:null},d.RGBA8)),s.distortionStrength>0&&(h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),d.copyTexSubImage2D(d.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const p=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(h,p),h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE);const f=[s.color.r,s.color.g,s.color.b,s.color.a],m=(i,r)=>{const n=ji(this._movement.getPosition(),i),a=s.dropletSizeX,l=s.dropletSizeX*s.dropletSizeYScale,h=t.width/2,m=t.height/2,_=Gi(0,s.screenThinning.start,0,1,s.screenThinning.intensity),g=Gi(.001,s.screenThinning.range,0,1,s.screenThinning.intensity),y=Gi(0,s.screenThinning.particleOffset,0,1,s.screenThinning.intensity),v=(b={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:s.velocityConeAperture,velocity:s.velocity,boxSize:i,rainDropletSize:[a,l],distortionStrength:s.distortionStrength,rainDirection:o,color:f,screenSize:[u.width,u.height],thinningCenterPos:[h,m],thinningShape:[_,g,Math.pow(10,s.screenThinning.fadePower)],thinningAffectedRatio:s.screenThinning.affectedRatio,thinningParticleOffset:y,shapeDirectionalPower:s.shapeDirPower,shapeNormalPower:s.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(b.modelview),u_projection:Float32Array.from(b.projection),u_time:b.time,u_cam_pos:b.camPos,u_texScreen:0,u_velocityConeAperture:b.velocityConeAperture,u_velocity:b.velocity,u_boxSize:b.boxSize,u_rainDropletSize:b.rainDropletSize,u_distortionStrength:b.distortionStrength,u_rainDirection:b.rainDirection,u_color:b.color,u_screenSize:b.screenSize,u_thinningCenterPos:b.thinningCenterPos,u_thinningShape:b.thinningShape,u_thinningAffectedRatio:b.thinningAffectedRatio,u_thinningParticleOffset:b.thinningParticleOffset,u_shapeDirectionalPower:b.shapeDirectionalPower,u_shapeNormalPower:b.shapeNormalPower,u_mode:b.mode});var b;const x=Math.round(s.intensity*this.particlesCount),w=e.ac.simpleSegment(0,0,4*x,2*x);p.draw(t,d.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.alphaBlended,e.$.disabled,v,"rain_particles",this.particlesVx,this.particlesIdx,w);};s.distortionStrength>0&&m(s.boxSize,!0),m(s.boxSize,!1),this._vignette.draw(t,n);}},Snow:class extends qi{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=Vi(this.particlesCount),s=new e.bl,r=new e.ad;let o=0;const n=e.bi(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=n(),l=n(),c=n(),h=[e/t.length,a,l,c],d=[n(),n()];s.emplaceBack(i[0],i[1],i[2],-1,-1,...h,...d),s.emplaceBack(i[0],i[1],i[2],1,-1,...h,...d),s.emplaceBack(i[0],i[1],i[2],1,1,...h,...d),s.emplaceBack(i[0],i[1],i[2],-1,1,...h,...d),r.emplaceBack(o+0,o+1,o+2),r.emplaceBack(o+0,o+2,o+3),o+=4;}this.particlesVx=i.createVertexBuffer(s,Zi.members),this.particlesIdx=i.createIndexBuffer(r);}}getDrawParams(e){if(!e.style.snow)return null;const t=e.style.snow.state,i=structuredClone(this._params);i.intensity=t.density,i.timeFactor=t.intensity,i.color=structuredClone(t.color),i.screenThinning.intensity=t.centerThinning,i.billboardSize=2.79*t.flakeSize;const s=structuredClone(this._vignetteParams);return s.strength=1,s.color=structuredClone(t.vignetteColor),{params:i,vignetteParams:s,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(t){const i=this.getDrawParams(t);if(!i)return;const{params:s,revealParams:r,direction:o,vignetteParams:n}=i,a=t.transform.zoom;if(r.revealStart>a)return;const l=Gi(0,1,r.revealStart,r.revealStart+r.revealRange,a);n.strength*=l;const c=this.updateOnRender(t,s.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const h=t.context,d=h.gl,u=t.transform,p=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(h,p),((i,s,r)=>{const n=ji(this._movement.getPosition(),i),a=u.width/2,l=u.height/2,h=Gi(0,r.screenThinning.start,0,1,r.screenThinning.intensity),f=Gi(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),m=Gi(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),_=(g={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,horizontalOscillationRadius:r.horizontalOscillationRadius,horizontalOscillationRate:r.horizontalOscillationRate,boxSize:i,billboardSize:1*r.billboardSize,simpleShapeParameters:[r.shapeFadeStart,r.shapeFadePower],screenSize:[u.width,u.height],thinningCenterPos:[a,l],thinningShape:[h,f,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:m,color:[r.color.r,r.color.g,r.color.b,r.color.a],direction:o},{u_modelview:Float32Array.from(g.modelview),u_projection:Float32Array.from(g.projection),u_time:g.time,u_cam_pos:g.camPos,u_velocityConeAperture:g.velocityConeAperture,u_velocity:g.velocity,u_horizontalOscillationRadius:g.horizontalOscillationRadius,u_horizontalOscillationRate:g.horizontalOscillationRate,u_boxSize:g.boxSize,u_billboardSize:g.billboardSize,u_simpleShapeParameters:g.simpleShapeParameters,u_screenSize:g.screenSize,u_thinningCenterPos:g.thinningCenterPos,u_thinningShape:g.thinningShape,u_thinningAffectedRatio:g.thinningAffectedRatio,u_thinningParticleOffset:g.thinningParticleOffset,u_particleColor:g.color,u_direction:g.direction});var g;const y=Math.round(r.intensity*this.particlesCount),v=e.ac.simpleSegment(0,0,4*y,2*y);this.particlesVx&&this.particlesIdx&&p.draw(t,d.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.alphaBlended,e.$.disabled,_,"snow_particles",this.particlesVx,this.particlesIdx,v);})(s.boxSize,0,s),this._vignette.draw(t,n);}},shaders:Bi,programUniforms:Xi,drawElevatedStructures:function(t){const{painter:i,sourceCache:s,layer:r,coords:o,colorMode:n}=t,a=i.context.gl,l=t.painter.shadowRenderer,c=!!l&&l.enabled,h=new e.Z(i.context.gl.LEQUAL,e.Z.ReadOnly,i.depthRangeFor3D);let d=[0,0,0];if(c){const t=i.style.directionalLight,s=i.style.ambientLight;t&&s&&(d=e.aF(i.style,t,s));}const u=t=>{for(const u of o){const o=s.getTile(u),p=o.getBucket(r);if(!p)continue;const f=p.hdExt?p.hdExt.elevatedStructures:void 0;if(!f)continue;let m,_;if(t?(m=f.renderableBridgeSegments,_=f.bridgeProgramConfigurations.get(r.id)):(m=f.renderableTunnelSegments,_=f.tunnelProgramConfigurations.get(r.id)),!m||0===m.segments[0].primitiveLength)continue;_.updatePaintBuffers(),i.prepareDrawTile();const g=i.isTileAffectedByFog(u),y=[];c&&y.push("RENDER_SHADOWS","NORMAL_OFFSET");const v=i.getOrCreateProgram("elevatedStructures",{config:_,overrideFog:g,defines:y}),b=i.translatePosMatrix(u.projMatrix,o,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));c&&l.setupShadows(o.tileID.toUnwrapped(),v,"vector-tile");const x=Hi(b,d);i.uploadCommonUniforms(i.context,v,u.toUnwrapped()),v.draw(i,a.TRIANGLES,h,e._.disabled,n,e.$.backCCW,x,r.id,f.vertexBuffer,f.indexBuffer,m,r.paint,i.transform.zoom,_,[f.vertexBufferNormal]);}};u(!0),u(!1);},drawElevatedFillShadows:function(t){const{painter:i,sourceCache:s,layer:r,coords:o}=t,n=i.context.gl,a=t.painter.shadowRenderer;for(const t of o){const o=s.getTile(t),l=o.getBucket(r);if(!l)continue;const c=l.hdExt?l.hdExt.elevatedStructures:void 0;if(!c)continue;if(!c.shadowCasterSegments||0===c.shadowCasterSegments.segments[0].primitiveLength)continue;i.prepareDrawTile();const h=l.bufferData.programConfigurations.get(r.id),d=i.isTileAffectedByFog(t),u=i.getOrCreateProgram("elevatedStructuresDepth",{config:h,overrideFog:d}),p=a.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());i.uploadCommonUniforms(i.context,u,t.toUnwrapped());const f=$i(p,0);u.draw(i,n.TRIANGLES,a.getShadowPassDepthMode(),e._.disabled,e.a1.disabled,e.$.disabled,f,r.id,c.vertexBuffer,c.indexBuffer,c.shadowCasterSegments,r.paint,i.transform.zoom,h);}},drawDepthPrepass:function(t,i,s,r,o){if(!i)return;if(!s.layout||"none"===s.layout.get("fill-elevation-reference")||0===s.paint.get("fill-opacity").constantOr(1))return;const n=t.context.gl,a=new e.Z(t.context.gl.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D),l=new e.Z(t.context.gl.GREATER,e.Z.ReadWrite,t.depthRangeFor3D),c=function(t){let i=.01;return t.isOrthographic&&(i=e.al(1e-4,i,e.bo(t.pitch>=e.bn?1:t.pitch/e.bn))),2*i}(t.transform),h=t.transform.getFreeCameraOptions().position,d="elevatedStructuresDepthReconstruct",u=t.getOrCreateProgram(d,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(d);for(const d of r){const r=i.getTile(d),f=r.getBucket(s);if(!f)continue;if(!f.hdExt)continue;const m=f.hdExt.elevatedStructures,_=f.hdExt.elevationBufferData;if(!m||!m.depthSegments||!_)continue;const g=_.heightRange,y=Ki(d.toUnwrapped(),h),v=t.translatePosMatrix(d.projMatrix,r,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));let b,x,w,T;if("initialize"===o){if(!g||g.min>=1||0===m.depthSegments.segments[0].primitiveLength)continue;b=Wi(v,y,c,1,0),x=a,w=m.depthSegments,T=u;}else if("reset"===o){if(!g||g.min>=0||0===m.maskSegments.segments[0].primitiveLength)continue;b=Wi(v,y,0,0,1),x=l,w=m.maskSegments,T=u;}else if("geometry"===o){if(0===m.depthSegments.segments[0].primitiveLength)continue;b=Wi(v,y,c,1,0),x=a,w=m.depthSegments,T=p;}T.draw(t,n.TRIANGLES,x,e._.disabled,e.a1.disabled,e.$.disabled,b,s.id,m.vertexBuffer,m.indexBuffer,w,s.paint,t.transform.zoom);}},drawGroundShadowMask:function(t,i,s,r){if(!i)return;if(!s.layout||"none"===s.layout.get("fill-elevation-reference")||0===s.paint.get("fill-opacity").constantOr(1))return;const o=t.context.gl,n=new e.Z(o.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D),a=new e._({func:o.ALWAYS,mask:255},255,255,o.KEEP,o.KEEP,o.REPLACE),l=t.transform.getFreeCameraOptions().position,c=t.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const h of r){const r=i.getTile(h),d=r.getBucket(s);if(!d)continue;const u=d.hdExt?d.hdExt.elevatedStructures:void 0;if(!u||!u.depthSegments||0===u.depthSegments.segments[0].primitiveLength)continue;const p=Ki(h.toUnwrapped(),l),f=t.translatePosMatrix(h.projMatrix,r,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor")),m=Wi(f,p,0,1,0);c.draw(t,o.TRIANGLES,n,a,e.a1.disabled,e.$.disabled,m,s.id,u.vertexBuffer,u.indexBuffer,u.depthSegments,s.paint,t.transform.zoom);}},IndoorManager:class extends e.E{constructor(t,i=!1){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Ti,this._initialLoadDone=!1,e.aV(["_updateUI"],this);const s=()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI();}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI));};i?(this._initialLoadDone=!0,s()):this._style.on("style.load",s);}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null;}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors());}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector();}setIndoorData(e){let t=!1;for(const[i,s]of Object.entries(e.buildings))if(this._buildings[i])for(const e of s.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],s.floors[e]):(this._buildings[i].floors[e]=s.floors[e],t=!0);else this._buildings[i]=s,t=!0;t&&this._recalculateActiveFloors();}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return {selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let s=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){s=e;break}const r=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return {selectedFloorId:s,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:r}}_updateUI(){this._initialLoadDone=!0;const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(e,t),this._updateIndoorSelector();}}_onBuildingTransition(e,t){if(!this._indoorState)return;const i=!!t&&!e;!t&&e?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0));}_updateIndoorSelector(){this.fire(new e.h("selector-update",this.getControlState()));}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0;}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.aW.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(e,t){if(e===t)return !0;if(!e||!t)return !1;if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector());}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry);}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,s=t.height;return [t.pointLocation(new e.P(0,0)),t.pointLocation(new e.P(i,0)),t.pointLocation(new e.P(i,s)),t.pointLocation(new e.P(0,s))].map(t=>new e.P(t.lng,t.lat))}},HdCoverageState:class{constructor(){this.coverageSourceCaches={},this.manager=new ts;}},updateFrcCoverage:function(e,t){t.manager.clear();for(const i in e._mergedHdRoadCoverageSourceCaches){const s=e._mergedHdRoadCoverageSourceCaches[i]._tiles;for(const e in s){const i=s[e];if(!i||!i.loaded())continue;const r=i.frcCoveragePolygons;t.manager.addTileCoverage(i.tileID.canonical,r&&r.length>0?r:[]);}}const i=t.manager.updateSnapshotIfNeeded();if(e.map.painter&&(e.map.painter.frcCoverageSnapshot=i.empty()?null:i),!i.empty()){const t=[e._mergedOtherSourceCaches,e._mergedSymbolSourceCaches];for(const e of t)for(const t in e){const i=e[t];for(const e in i._tiles){const t=i._tiles[e];t&&t.hasDeferredRoadStructure&&(t.hasDeferredRoadStructure=!1,i._reloadTile(+e,"reloading"));}}}},updateHdCoverageSourceCache:function(t,i,s){if("fill"!==s.type||s.sourceLayer!==e.bU)return;if(i.coverageSourceCaches[s.source])return;const r=t.getOwnSource(s.source);if(!r||"vector"!==r.type)return;const o=`hd-road-coverage:${s.source}`,n=e.m(o,t.scope),a=t._sourceCaches[o]=new gs(n,r,e.bR.HdRoadCoverage);i.coverageSourceCaches[s.source]=a,a.setMaxzoomOverride(14),a.onAdd(t.map);const l=t._otherSourceCaches[s.source];l&&l._sourceLoaded&&(a._sourceLoaded=!0);},updateFrcCoverageFadeRange:function(t,i){let s=null,r=null;const o={globals:{zoom:0}};t.forEachFragmentStyle(i=>{if(s)return;const n=i.stylesheet?i.stylesheet.schema:null;if(!n||!n.sdCoverageFadeRange)return;const a=e.m("sdCoverageFadeRange",i.scope),l=i.options?i.options.get(a):void 0,c=l?l.value||l.default:null;if(c){const e=c.evaluate(o);Array.isArray(e)&&2===e.length&&(e[0]>0||e[1]>0)&&(s=[e[0],e[1]]);}const h=e.m("sdCoverageSourceLayers",i.scope),d=i.options?i.options.get(h):void 0,u=d?d.value||d.default:null;if(u){const e=u.evaluate(o);Array.isArray(e)&&e.length>0&&(r=e);}else {const e=t.stylesheet&&t.stylesheet.imports||[];for(const t of e)if(t.id===i.scope){const e=t.config?t.config.sdCoverageSourceLayers:void 0;Array.isArray(e)&&e.length>0&&(r=e);break}}}),i.frcCoverageFadeRange=s,i.frcCoverageSourceLayers=null!=s?r||["road","structure"]:[];},HdElevationState:Fs,setupAndUpdateElevationCoverage:function(t){if(!function(e){for(const t in e._mergedLayers)if(Ds(e._mergedLayers[t]))return !0;return !1}(t))return void Bs(t);const i=Gt(t,t.map&&t.map.transform);t._hdElevation||(t._hdElevation=new Fs);const s=t._hdElevation._terrainActiveLast;if(t._hdElevation._terrainActiveLast=i,void 0!==s&&s!==i&&Ms(t,void 0,!0),i)return void(t.map.painter&&(t.map.painter.elevationCoverageSnapshot=null));if(!Rs(t))return void Bs(t);void 0===s&&Ms(t,void 0,!0);const r=t._hdElevation;r._needsCrossSourceElevation=!0,t._crossSourceElevationActive=!0,r._ingestFQIDs=As(t);const o=Ls(t);t.forEachFragmentStyle(t=>{for(const i of o){if(!Cs(i,t.scope))continue;const s=e.bV(i);if(t._otherSourceCaches[s]||t._symbolSourceCaches[s])continue;const r=t.getOwnSource(s);r&&"vector"===r.type&&(t._hdElevation||(t._hdElevation=new Fs),ks(t,t._hdElevation,r));}}),t.mergeSources(),zs(t,r);},updateElevationCoverage:zs,updateHdElevationSourceCache:ks,markElevationIngestSourceCachesUsed:function(e){if(!e._hdElevation||!e._hdElevation._needsCrossSourceElevation)return;const t=e._hdElevation._ingestFQIDs;if(t)for(const i of t){const t=Es(e,i);t&&(t.used=!0);}},updateCrossSourceElevationGate:function(e){e._crossSourceElevationActive=Rs(e);const t=e._mergedHdRoadElevationSourceCaches;t&&0!==Object.keys(t).length&&(e._hdElevation||(e._hdElevation=new Fs),e._hdElevation._needsCrossSourceElevation=e._crossSourceElevationActive);},buildElevationRequestParams:function(t,i,s){if(i.renderSourceType===e.bR.HdRoadElevation)return null;if(Gt(t.style,t.transform))return null;if(!s)return null;const r=t.painter?t.painter.elevationCoverageSnapshot:null,o=!(!t.painter||!t.painter.elevationProvidersReady);return r?function(e,t,i){const s=e.getTilesIntersecting(t);if(0===s.length)return {registry:[],hasCoveringTile:!1,allProvidersReady:i};const r=[];for(const e of s)for(const t of e.features)r.push({tileId:e.tileId,feature:t});return r.sort((e,t)=>e.feature.id-t.feature.id),{registry:r,hasCoveringTile:!0,allProvidersReady:i}}(r,i.tileID.canonical,o):{registry:[],hasCoveringTile:!1,allProvidersReady:o}},FrcCoverageRenderer:class{constructor(){this.tileBuffers=new Map,this._context=null;}update(e,t){this._context=e;const i=new Set;for(const s of t){if(0===s.frcMask)continue;let t=!1;for(const e of s.polygons)if(e.hasGeometry()){t=!0;break}if(!t)continue;const r=`${s.tileId.z}/${s.tileId.x}/${s.tileId.y}`;if(i.add(r),!this.tileBuffers.has(r)){const t=this._createBuffers(e,s);t&&this.tileBuffers.set(r,t);}}for(const e of this.tileBuffers.keys())if(!i.has(e)){const t=this.tileBuffers.get(e);t.vertexBuffer.destroy(),t.indexBuffer.destroy();for(const e of t.frcLevelSegments)e&&e.destroy();this.tileBuffers.delete(e);}}getBuffers(e){return this.tileBuffers.get(`${e.z}/${e.x}/${e.y}`)||null}destroy(){for(const e of this.tileBuffers.values()){e.vertexBuffer.destroy(),e.indexBuffer.destroy();for(const t of e.frcLevelSegments)t&&t.destroy();}this.tileBuffers.clear();}_createBuffers(t,i){const s=new e.bC,r=new e.ad,o=[];for(const t of i.polygons){if(!t.hasGeometry()||0===t.rings.length)continue;const i=s.length,n=r.length,a=s.length,l=[],c=[];let h=0;for(let e=0;e<t.rings.length;e++){const i=t.rings[e];if(!(i.length<3)){e>0&&c.push(h);for(const e of i)s.emplaceBack(e.x,e.y),l.push(e.x,e.y),h++;}}const d=e.bF(l,c.length>0?c:void 0);for(let e=0;e<d.length;e+=3)r.emplaceBack(a+d[e],a+d[e+1],a+d[e+2]);o.push({vertexOffset:i,indexOffset:n,vertexCount:s.length-i,indexCount:r.length-n,frcMask:t.frcMask});}if(0===s.length)return null;const n=new Array(9).fill(null);for(let t=0;t<9;++t){const s=1<<t;if(0===(i.frcMask&s))continue;let r=1/0,a=0,l=0,c=!1;for(const e of o)0!==(e.frcMask&s)&&(r=Math.min(r,e.indexOffset),a=Math.max(a,e.indexOffset+e.indexCount),l=Math.max(l,e.vertexOffset+e.vertexCount),c=!0);c&&(n[t]=e.ac.simpleSegment(0,r,l,a-r));}return {vertexBuffer:t.createVertexBuffer(s,e.bE.members),indexBuffer:t.createIndexBuffer(r),frcLevelSegments:n}}},drawFillFrcCoverageFirstPass:function(t){const{painter:i,bucket:s,coord:r,elevatedGeometry:o}=t,n="road"===s.sourceLayerName,a="structure"===s.sourceLayerName;if(!n&&!a)return "fallthrough";if(!i.frcCoverageSnapshot||o)return "fallthrough";const l=i.frcCoverageSnapshot.getTileOrParent(r.canonical);if(!l||0===l.frcMask)return "fallthrough";const c=s.hdExt&&s.hdExt.frcData,h=!!c&&!c.empty(),d=$s(l.polygons);if(a&&!d)return "skip";if(a&&d)return t.polygonCoverageTiles.push({coord:t.coord,bufferData:t.bufferData,program:t.program,programConfiguration:t.programConfiguration,uniformValues:t.uniformValues,depthMode:t.depthMode,dynamicBuffers:t.dynamicBuffers,indexBuffer:t.indexBuffer,segments:t.segments,frcMask:l.frcMask}),"deferred";if(n&&h&&c){const s=l.frcMask,r=i.transform.zoom;for(const[o,n]of c.frcPerLevel)s&1<<o||0!==n.segments.length&&t.program.draw(i,t.drawMode,t.depthMode,t.stencilMode,t.colorMode,e.$.disabled,t.uniformValues,t.layer.id,t.bufferData.layoutVertexBuffer,t.indexBuffer,n,t.layer.paint,r,t.programConfiguration,t.dynamicBuffers);return c.frcNonRoadSegments.segments.length>0&&t.program.draw(i,t.drawMode,t.depthMode,t.stencilMode,t.colorMode,e.$.disabled,t.uniformValues,t.layer.id,t.bufferData.layoutVertexBuffer,t.indexBuffer,c.frcNonRoadSegments,t.layer.paint,r,t.programConfiguration,t.dynamicBuffers),"drawn"}return "fallthrough"},drawFillFrcCoverageSecondPass:function(t,i,s,r,o){if(0===s.length)return;const n=Hs(t),a=t.transform.zoom,l=(s,n,l)=>{1!==l&&(s.uniformValues.u_opacity_multiplier=l),s.program.draw(t,r,s.depthMode,n,o,e.$.disabled,s.uniformValues,i.id,s.bufferData.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,a,s.programConfiguration,s.dynamicBuffers),1!==l&&(s.uniformValues.u_opacity_multiplier=1);};Zs(t,s,n,(e,t,i)=>l(e,i,1),(e,t,i)=>l(e,i,n));},drawLineFrcCoverageDetect:function(e,t,i,s,r,o,n,a,l,c){const h=t.hdExt&&t.hdExt.frcData;if(!h||0===h.frcPerLevel.size)return null;if(!e.frcCoverageSnapshot||s)return null;const d=e.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!d||0===d.frcMask)return null;const u=$s(d.polygons),p=e.frcCoverageFadeRange,f=null!=p&&e.transform.zoom>=p[0];if(u&&f){let e=!1;for(const t of h.frcPerLevel.keys())if(d.frcMask&1<<t){e=!0;break}e&&c.push({coord:i,bucket:t,uniformValues:r,programConfiguration:o,program:n,depthMode:a,colorMode:l,frcMask:d.frcMask});}return {coverageTile:d,frcMask:d.frcMask,active:f,hasPolygonGeometry:u}},drawLineFrcRenderLine:function(e,t,i,s){const r=e.hdExt&&e.hdExt.frcData;if(!r)return;const o=t.frcMask;for(const[e,t]of r.frcPerLevel)o&1<<e||s(i,t);const n=r.frcNonRoadSegments;n.segments.length>0&&s(i,n);},drawLineFrcFadePass:function(e,t,i,s,r,o,n){if(s.hasPolygonGeometry)return;const a=t.hdExt&&t.hdExt.frcData;if(!a||!e.frcCoverageFadeRange)return;const[l,c]=e.frcCoverageFadeRange;if(l>=c)return;const h=1-Math.max(0,Math.min(1,(e.transform.zoom-l)/(c-l)));if(h<=0)return;const d=r?o:e.stencilModeForClipping(i),u=s.frcMask;for(const[e,t]of a.frcPerLevel)u&1<<e&&n(d,t,h);},drawLineFrcCoverageSecondPass:function(t,i,s){if(0===s.length)return;const r=t.context.gl,o=Hs(t),n=t.transform.zoom,a=(s,o,a,l)=>{const c=s.bucket.hdExt&&s.bucket.hdExt.frcData,h=c&&c.frcPerLevel.get(o);h&&0!==h.segments.length&&(1!==l&&(s.uniformValues.u_opacity_multiplier=l),s.program.draw(t,r.TRIANGLES,s.depthMode,a,s.colorMode,e.$.disabled,s.uniformValues,i.id,s.bucket.layoutVertexBuffer,s.bucket.indexBuffer,h,i.paint,n,s.programConfiguration,[s.bucket.layoutVertexBuffer2,s.bucket.patternVertexBuffer,s.bucket.zOffsetVertexBuffer,s.bucket.elevationIdColVertexBuffer,s.bucket.elevationGroundScaleVertexBuffer]),1!==l&&(s.uniformValues.u_opacity_multiplier=1));};Zs(t,s,o,(e,t,i)=>a(e,t,i,1),(e,t,i)=>a(e,t,i,o));}},Xs=Ws;async function Ks(){return Promise.resolve()}class Ys{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i);}static createFromScreenPoints(t,i){let s,r;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);s=[o],r=i.isPointAboveHorizon(o);}else {const o=e.P.convert(t[0]),n=e.P.convert(t[1]),a=o.add(n)._div(2);s=[o,n],r=e.bZ(o,n).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a);}return new Ys(s,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.bZ(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],s=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.bZ(i,s,0,!1);return this.cameraPoint.y>s.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<s.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=s.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.b_(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],s=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.bZ(i,s,t),o=this.cameraPoint.clone(),n=Number(o.x>i.x)+Number(o.x>s.x);switch(3*(Number(o.y>i.y)+Number(o.y>s.y))+n){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o;}return r}containsTile(t,i,s,r=0,o){const n=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,a=s?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let l=t.tileID.wrap+(a.unwrapped?r:0);const c=a.polygon.map(i=>e.b$(t.tileTransform,i,l));if(!e.c0(c,0,0,e.a2,e.a2))return;l=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const h=this.screenGeometryMercator.polygon.map(i=>e.c1(t.tileTransform,i,l)),d=h.map(t=>new e.P(t[0],t[1])),u=e.c1(t.tileTransform,o,l),p=h.map(t=>{const i=e.c2(t,t,u);return e.c3(i,i),new e.c4(u,i)}),f=e.c5(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:d,tilespaceRays:p,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:(m=e.c6(c),m.min.x=e.b0(m.min.x,0,e.a2),m.min.y=e.b0(m.min.y,0,e.a2),m.max.x=e.b0(m.max.x,0,e.a2),m.max.y=e.b0(m.max.y,0,e.a2),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m;}_bufferedScreenMercator(e,t){const i=er(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let s;return s="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=s,s}}_bufferedCameraMercator(e,t){const i=er(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let s;return s="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=s,s}}_projectAndResample(t,i){const s=function(t,i){const s=e.X([],i.pixelMatrix,i.globeMatrix),r=[0,-e.c8,0,1],o=[0,e.c8,0,1],n=[0,0,0,1];e.c7(r,r,s),e.c7(o,o,s),e.c7(n,n,s);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.c9(t,a)&&r[3]<n[3],h=e.c9(t,l)&&o[3]<n[3];if(!c&&!h)return null;const d=function(e,t,i){for(let s=1;s<e.length;s++){const r=Js(t.pointCoordinate3D(e[s-1]).x),o=Js(t.pointCoordinate3D(e[s]).x);if(i<0){if(r<o)return {idx:s,t:-r/(o-1-r)}}else if(o<r)return {idx:s,t:(1-r)/(o+1-r)}}return null}(t,i,c?-1:1);if(!d)return null;const{idx:u,t:p}=d;let f=u>1?Qs(t.slice(0,u),i):[],m=u<t.length?Qs(t.slice(u),i):[];f=f.map(t=>new e.P(Js(t.x),t.y)),m=m.map(t=>new e.P(Js(t.x),t.y));const _=[...f];0===_.length&&_.push(m.at(-1));const g=_.at(-1),y=e.al(g.y,(0===m.length?f[0]:m[0]).y,p);let v;return v=c?[new e.P(0,y),new e.P(0,0),new e.P(1,0),new e.P(1,y)]:[new e.P(1,y),new e.P(1,1),new e.P(0,1),new e.P(0,y)],_.push(...v),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map(t=>new e.bS(t.x,t.y)),unwrapped:!1}}(t,i);if(s)return s;const r=function(t,i){let s=!1,r=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>r&&(r=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const i=(o+e)%(t.length-1),r=t[i],n=t[i+1];Math.abs(r.x-n.x)>.5&&(r.x<n.x?(r.x+=1,0===i&&(t.at(-1).x+=1)):(n.x+=1,i+1===t.length-1&&(t[0].x+=1)),s=!0);}const n=e.a7(i.center.lng);return s&&n<Math.abs(n-1)&&t.forEach(e=>{e.x-=1;}),{polygon:t,unwrapped:s}}(Qs(t,i).map(t=>new e.P(Js(t.x),t.y)),i);return {polygon:r.polygon.map(t=>new e.bS(t.x,t.y)),unwrapped:r.unwrapped}}}function Qs(t,i){return e.ca(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;},1/256)}function Js(e){return e<0?1+e%1:e%1}function er(e){return 100*e|0}class tr extends e.E{constructor(t,i,s,r){if(super(),this.id=t,this.dispatcher=s,this.type="vector",this.provider=i.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,e.cb(i,["url","scheme","tileSize","promoteId"])),this._options={type:"vector",...i},this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.cc;}load(t){this._loaded=!1,this.fire(new e.h("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,s=this.map.getWorldview(),r=(r,o)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),s&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${s}`),this.fire(new e.f(r))):o&&(this._setTileJSON(o),Xs.updateCrossSourceElevationGate&&this.map.style&&Xs.updateCrossSourceElevationGate(this.map.style),e.ck(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.h("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);};this.provider=this._options.provider;const o=e.cd(this._options);return o instanceof Error?(this._loaded=!0,this.fire(new e.f(o)),void(t&&t())):this.provider&&!o?(this._loaded=!0,this.fire(new e.f(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=o?this.loadTileJSONWithProvider(o,r):e.ce(this._options,this.map._requestManager,i,s,r))}loadTileJSONWithProvider(t,i){this.provider=t.name;const s=new AbortController;return (async()=>{const{request:r,options:o}=await e.cl(this._options,this.map._requestManager,s.signal);if(s.signal.aborted)return;const n=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:o,request:r},{signal:s.signal});if(s.signal.aborted)return;const a=n?n.find(e=>null!=e):null,l=e.cm(this._options,a,this.map._requestManager);l instanceof Error?i(l):i(null,l);})().catch(e=>{s.signal.aborted||i(e);}),{cancel:()=>s.abort()}}_setTileJSON(t){if(Object.assign(this,t),this.hasWorldviews=!!t.worldview_options,t.worldview_default&&(this.worldviewDefault=t.worldview_default),t.vector_layers){this.vectorLayers=t.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of t.vector_layers)this.vectorLayerIds.push(e.id),t.worldview&&t.worldview[e.source]&&this.localizableLayerIds.add(e.id);}this.tileBounds=e.cf.fromTileJSON(t);}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.m(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return {...this._options}}async loadTile(t,i){const s=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(s),o=!t.actor||"expired"===t.state;if(!o&&"loading"===t.state)return void(t.reloadCallback=i);o&&(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor());const n=new AbortController;t.request=n;try{const a=await this.map._requestManager.transformRequest(r,e.R.Tile,n.signal);if(n.signal.aborted)return i(null);this.dispatchTile(t,r,s,a,n,o,i);}catch(e){if(n.signal.aborted)return i(null);i(e);}}dispatchTile(t,i,s,r,o,n,a){const l=this.map.style?this.map.style.getLut(this.scope):null,c=l?{image:l.image.clone()}:null,h=!(!this.map.style||!this.map.style._crossSourceElevationActive),d=!(!this.map.style||!h),u={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:c,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,frcCoverage:(()=>{const e=this.map.painter,i=e?e.frcCoverageFadeRange:null;if(null==i)return null;const s=e?e.frcCoverageSnapshot:null,r=this.map.transform.zoom<i[0],o=s?s.getTileOrParent(t.tileID.canonical):null,n=t.tileID.overscaledZ>=Math.ceil(i[1]),a=s&&n?s.getFullCoverageMask(t.tileID.canonical):null;return {frcMask:n?a??null:null,resolved:r||null!=s,polygons:o&&0!==o.frcMask?o.polygons:null,tileZoom:o&&0!==o.frcMask?o.tileId.z:null,sourceLayers:e?e.frcCoverageSourceLayers:["road","structure"]}})(),terrainEnabled:Gt(this.map.style,this.map.transform),crossSourceElevationEnabled:d,elevation:Xs.buildElevationRequestParams?Xs.buildElevationRequestParams(this.map,t,h):null,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.cg(s)&&(u.localizableLayerIds=this.localizableLayerIds),u.request.collectResourceTiming=this._collectResourceTiming,n)if(this.dispatcher.ready||this.provider)t.request=t.actor.sendCancelable("loadTile",u,{},p.bind(this));else {const i=e.ch.call({deduped:this._deduped},u,(e,i)=>{t.aborted||(e||!i?p.call(this,e):(u.data={rawData:i.rawData.slice(0),headers:i.headers},t.actor&&(t.request=t.actor.sendCancelable("loadTile",u,{},p.bind(this)))));},!0);o.signal.addEventListener("abort",i,{once:!0});}else t.request=t.actor.sendCancelable("reloadTile",u,{},p.bind(this));function p(i,s){return delete t.request,t.aborted?a(null):i?a(i):(s&&s.resourceTiming&&(t.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&t.setExpiryData(e.ci(s.headers)),void function(){if(t.aborted)return a(null);t.loadVectorData(s,this.map.painter),e.cj(this.dispatcher),a(null,s),t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null);}.call(this))}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){e.actor&&e.actor.notify("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class ir extends e.E{constructor(t,i,s,r){super(),this.id=t,this.dispatcher=s,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={type:"raster",...i},Object.assign(this,e.cb(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.h("dataloading",{dataType:"source"}));const i=this.map.getWorldview(),s=(i,s)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.f(i)):s&&(Object.assign(this,s),s.raster_layers&&(this.rasterLayers=s.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=e.cf.fromTileJSON(s),e.ck(s.tiles),this.fire(new e.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.h("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);};this.provider="string"==typeof this._options.provider?this._options.provider:void 0,this._tileProvider=void 0;const r=e.cd(this._options);return r instanceof Error?(this._loaded=!0,this.fire(new e.f(r)),void(t&&t())):this.provider&&!r?(this._loaded=!0,this.fire(new e.f(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=r?this.loadTileJSONWithProvider(r,s):e.ce(this._options,this.map._requestManager,null,i,s))}loadTileJSONWithProvider(t,i){this.provider=t.name;const s=new AbortController;return (async()=>{const{request:r,options:o}=await e.cl(this._options,this.map._requestManager,s.signal);if(s.signal.aborted)return;const n=await e.cn(t.name,t.url);if(s.signal.aborted)return;const a=new n(o);let l=null;if(a.load&&r&&(l=await a.load({request:r}),s.signal.aborted))return;this._tileProvider=a;const c=e.cm(this._options,l,this.map._requestManager);c instanceof Error?i(c):i(null,c);})().catch(e=>{s.signal.aborted||i(new Error(`Could not load tile provider ${t.name}`,{cause:e}));}),{cancel:()=>s.abort()}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.m(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return {...this._options}}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(t,i){const s=e.e.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),s,this.tileSize),o=new AbortController;if(t.request=o,this._tileProvider)this.loadTileWithProvider(t,this._tileProvider,r,o,i);else try{const s=await this.map._requestManager.transformRequest(r,e.R.Tile,o.signal);if(o.signal.aborted)return delete t.request,i(null);const{data:n,headers:a}=await e.a(s,o.signal);if(delete t.request,t.aborted)return i(null);const l=e.ci(a);this.map._refreshExpiredTiles&&t.setExpiryData(l),t.setTexture(n,this.map.painter),t.state="loaded",e.cj(this.dispatcher),i(null);}catch(e){if(delete t.request,o.signal.aborted)return i(null);t.state="errored",i(e);}}async loadTileWithProvider(t,i,s,r,o){const{z:n,x:a,y:l}=t.tileID.canonical;try{const c=await this.map._requestManager.transformRequest(s,e.R.Tile,r.signal);if(r.signal.aborted)return o(null);const h=await i.loadTile({z:n,x:a,y:l},{request:c,signal:r.signal});if(r.signal.aborted)return o(null);if(null==h){const e=new Error("Tile not found");return e.status=404,t.state="errored",o(e)}if(null==h.data)return t.state="loaded",o(null);const d=h.data instanceof ImageBitmap?h.data:await createImageBitmap(new Blob([h.data]));if(r.signal.aborted)return o(null);t.setTexture(d,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:h.cacheControl,expires:h.expires}),o(null);}catch(e){if(r.signal.aborted)return o(null);t.state="errored",o(new Error(`Could not load tile from ${s}`,{cause:e}));}finally{delete t.request;}}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),t&&t();}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function sr(t,i,s,r,o,n,a,l){const c=[t,i,1,s,r,1,o,n,1],h=[a,l,1],d=e.cu([],c),[u,p,f]=e.ct(h,h,d);return e.cv(c,c,[u,0,0,0,p,0,0,0,f])}function rr(t,i,s,r,o,n,a,l){const c=function(t,i,s,r,o,n,a,l){const c=sr(0,0,1,0,1,1,0,1),h=sr(t,i,s,r,o,n,a,l),d=e.cu([],c);return e.cv(h,h,d)}(t,i,s,r,o,n,a,l);return [c[2]/c[8]/e.a2,c[5]/c[8]/e.a2]}function or(t){return [t[0],Math.min(Math.max(t[1],-e.cp),e.cp)]}class nr extends e.E{constructor(e,t,i,s){super(),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.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(s),this.options=t,this._dirty=!1;}async load(t,i){if(this._loaded=i||!1,this.fire(new e.h("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();const s=new AbortController;this._imageRequest=s;try{const i=await this.map._requestManager.transformRequest(this.url,e.R.Image,s.signal),{data:r}=await e.a(i,s.signal);this._imageRequest=null,this._loaded=!0,this.image=r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading();}catch(t){if(s.signal.aborted)return;this._imageRequest=null,this._loaded=!0,this.fire(new e.f(t));}}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.abort(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new e.co(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.h("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(t){this._imageRequest&&(this._imageRequest.abort(),this._imageRequest=null),!this.texture||this.texture instanceof e.co||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=t[0][1],s=t[0][1];for(const e of t)e[1]>s&&(s=e[1]),e[1]<i&&(i=e[1]);const r=(s+i)/2;if(r>e.cp?this.onNorthPole=!0:r<-e.cp&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const i=t.map(e.bS.fromLngLat);this.tileID=function(t){let i=1/0,s=1/0,r=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),o=Math.max(o,e.y);const n=Math.max(r-i,o-s),a=Math.max(0,Math.floor(-Math.log2(n))),l=Math.pow(2,a);let c=Math.floor((i+r)/2*l);return c>1&&(c-=1),new e.bX(a,c,Math.floor((s+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new e.h("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof e.co||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=e.bp(new e.bX(0,0,0),this.map.transform.projection),s=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,s=e[2].x-e[1].x,r=e[2].y-e[1].y,o=e[3].x-e[2].x,n=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-s*i,h=s*n-o*r,d=o*l-a*n,u=a*i-t*l;return c>0&&h>0&&d>0&&u>0||c<0&&h<0&&d<0&&u<0}(s))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const r=e.bp(this.tileID,this.map.transform.projection),[o,n,a,l]=this.coordinates.map(t=>{const i=r.projection.project(t[0],t[1]);return e.b$(r,i)._round()});this.perspectiveTransform=rr(o.x,o.y,n.x,n.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new e.bs;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(n.x,n.y,e.a2,0),c.emplaceBack(l.x,l.y,0,e.a2),c.emplaceBack(a.x,a.y,e.a2,e.a2),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,hs.members),this.boundsSegments=e.ac.simpleSegment(0,0,4,2);const h=e.cs,d=h+1,u=h+1,p=d*u,f=h*h*2,m=[],_=function(e){return [or(e[0]),or(e[1]),or(e[2]),or(e[3])]}(this.coordinates),[g,y,v,b]=function(e){let t=e[0][0],i=t,s=e[0][1],r=s;for(let o=1;o<e.length;o++)e[o][0]<t?t=e[o][0]:e[o][0]>i&&(i=e[o][0]),e[o][1]<s?s=e[o][1]:e[o][1]>r&&(r=e[o][1]);return [t,s,i-t,r-s]}(_);{const r=new e.bs,[o,n,a,l]=function(e){let t=e[0].x,i=t,s=e[0].y,r=s;for(let o=1;o<e.length;o++)e[o].x<t?t=e[o].x:e[o].x>i&&(i=e[o].x),e[o].y<s?s=e[o].y:e[o].y>r&&(r=e[o].y);return [t,s,i-t,r-s]}(s),c=e=>[(e.x-o)/a,(e.y-n)/l],[p,f,_,x]=s.map(c),w=function(t,i,s,r,o,n,a,l){const c=sr(0,0,1,0,1,1,0,1),h=sr(t,i,s,r,o,n,a,l),d=e.cu([],h);return e.cv(c,c,d)}(p[0],p[1],f[0],f[1],_[0],_[1],x[0],x[1]);this.elevatedGlobePerspectiveTransform=rr(p[0],p[1],f[0],f[1],_[0],_[1],x[0],x[1]);const T=(t,i)=>{m.push(t.lng);const s=Math.round((t.lng-g)/v*e.a2),o=Math.round((t.lat-y)/b*e.a2),n=c(i),a=e.ct([],[n[0],n[1],1],w),l=Math.round(a[0]/a[2]*e.a2),h=Math.round(a[1]/a[2]*e.a2);r.emplaceBack(s,o,l,h);},S=s[3].x-s[0].x,C=s[3].y-s[0].y,E=s[2].x-s[1].x,I=s[2].y-s[1].y;for(let e=0;e<u;e++){const t=e/h,r=[s[0].x+t*S,s[0].y+t*C],o=[s[1].x+t*E,s[1].y+t*I],n=o[0]-r[0],a=o[1]-r[1];for(let e=0;e<d;e++){const t=e/h,s={x:r[0]+n*t,y:r[1]+a*t};T(i.projection.unproject(s.x,s.y),s);}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(r,hs.members);}{this.maxLongitudeTriangleSize=0;let i=[],s=new e.ad;const r=(e,t,r)=>{s.emplaceBack(e,t,r);const o=m[e],n=m[t],a=m[r],l=Math.min(Math.min(o,n),a),c=Math.max(Math.max(o,n),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),i.push(l+c/2);};for(let e=0;e<h;e++)for(let t=0;t<h;t++){const i=e*d+t,s=i+1,o=i+d,n=o+1;r(i,o,s),r(s,o,n);}[i,s]=function(t,i){const s=Array.from({length:t.length},(e,t)=>t);s.sort((e,i)=>t[e]-t[i]);const r=[],o=new e.ad;for(let e=0;e<s.length;e++){const n=s[e];r.push(t[n]);const a=3*n,l=a+1;o.emplaceBack(i.uint16[a],i.uint16[l],i.uint16[l+1]);}return [r,o]}(i,s),this.elevatedGlobeTrianglesCenterLongitudes=i,this.elevatedGlobeIndexBuffer=t.createIndexBuffer(s);}this.elevatedGlobeSegments=e.ac.simpleSegment(0,0,p,f),this.elevatedGlobeGridMatrix=new Float32Array([0,v/e.a2,0,b/e.a2,0,0,y,g,0]);}prepare(){const t=0!==Object.keys(this.tiles).length;if(this.tileID&&!t)return;const i=this.map.painter.context,s=i.gl;!this._dirty||this.texture instanceof e.co||(this.texture?this.texture.update(this.image):(this.texture=new e.T(i,this.image,s.RGBA8),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE)),this._dirty=!1),t&&this._prepareData(i);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null));}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}getSegmentsForLongitude(t){const i=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!i)return null;const s=this.elevatedGlobeTrianglesCenterLongitudes;let r=(o=t+180)+360*Math.round((s[0]-o)/360);var o;const n=new e.ac,a=(e,t)=>{n.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:i.segments[0].vertexLength,primitiveLength:t,sortKey:void 0,vaos:{}});},l=.51*this.maxLongitudeTriangleSize;if(Math.abs(s[0]-r)<=l){const t=e.cq(s,0,s.length,r+l);return t===s.length||a(t,e.cr(s,t+1,s.length,r+360-l)-t),n}r<s[0]&&(r+=360);const c=e.cr(s,0,s.length,r-l);if(c===s.length)return a(0,s.length),n;a(0,c-0);const h=e.cq(s,c+1,s.length,r+l);return h!==s.length&&a(h,s.length-h),n}}const ar={vector:tr,raster:ir,"raster-dem":class extends ir{constructor(e,t,i,s){super(e,t,i,s),this.type="raster-dem",this.maxzoom=22,this._options={type:"raster-dem",...t},this.encoding=t.encoding||"mapbox";}loadTileJSONWithProvider(t,i){this.provider=t.name;const s=new AbortController;return (async()=>{const{request:r,options:o}=await e.cl(this._options,this.map._requestManager,s.signal);if(s.signal.aborted)return;const n=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:o,request:r},{signal:s.signal});if(s.signal.aborted)return;const a=n?n.find(e=>null!=e):null,l=e.cm(this._options,a,this.map._requestManager);l instanceof Error?i(l):i(null,l);})().catch(e=>{s.signal.aborted||i(e);}),{cancel:()=>s.abort()}}async loadTile(t,i){if(t.actor&&"expired"!==t.state)return;const s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.actor=this.dispatcher.getActor();const r=new AbortController;t.request=r;try{const o=await this.map._requestManager.transformRequest(s,e.R.Tile,r.signal);if(r.signal.aborted)return i(null);t.request=t.actor.sendCancelable("loadTile",{uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:o,encoding:this.encoding},{},function(s,r){return delete t.request,t.aborted?i(null):s?(t.state="errored",i(s)):(r&&(this.map._refreshExpiredTiles&&t.setExpiryData(e.ci(r.headers)),r.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=r.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0),t.state="loaded",void i(null))}.bind(this));}catch(e){if(r.signal.aborted)return i(null);t.state="errored",i(e);}}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),t&&t();}_getNeighboringTiles(t){const i=t.canonical,s=Math.pow(2,i.z),r=(i.x-1+s)%s,o=0===i.x?t.wrap-1:t.wrap,n=(i.x+1+s)%s,a=i.x+1===s?t.wrap+1:t.wrap,l={};return l[new e.bP(t.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new e.bP(t.overscaledZ,a,i.z,n,i.y).key]={backfilled:!1},i.y>0&&(l[new e.bP(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.bP(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.bP(t.overscaledZ,a,i.z,n,i.y-1).key]={backfilled:!1}),i.y+1<s&&(l[new e.bP(t.overscaledZ,o,i.z,r,i.y+1).key]={backfilled:!1},l[new e.bP(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.bP(t.overscaledZ,a,i.z,n,i.y+1).key]={backfilled:!1}),l}},geojson:class extends e.E{constructor(t,i,s,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=s.getActor(),this.setEventedParent(r),this._data=i.data,this._options={...i},this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=e.a2/this.tileSize;this.workerOptions={source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:e.a2,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.a2,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic,...i.workerOptions};}onAdd(e){this.map=e,this.setData(this._data);}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new e.f(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new e.f(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const e=new Map;for(const t of this._data.features)e.set(t.id,t);for(const i of t.features)e.set(i.id,i);this._data.features=[...e.values()];}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope}).then(e=>t(null,e)).catch(e=>t(e)),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope}).then(e=>t(null,e)).catch(e=>t(e)),this}getClusterLeaves(e,t,i,s){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i}).then(e=>s(null,e)).catch(e=>s(e)),this}async _updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.h("dataloading",{dataType:"source"})),this._loaded=!1;const i={append:t,...this.workerOptions};i.scope=this.scope;const s=this._data,r=new AbortController;this._pendingLoad=r;try{if("string"==typeof s){if(i.request=await this.map._requestManager.transformRequest(e.e.resolveURL(s),e.R.Source,r.signal),r.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);i.request.collectResourceTiming=this._collectResourceTiming;}else i.data=JSON.stringify(s);const o=await this.actor.send(`${this.type}.loadData`,i,{signal:r.signal});this._loaded=!0,this._pendingLoad=null;const n={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(n.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.h("data",n)),this._partialReload=!1,this._metadataFired=!0;}catch(t){if(r.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);this._loaded=!0,this._pendingLoad=null,this.fire(new e.f(t));}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);}loaded(){return this._loaded}reload(){const t=e.m(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData();}loadTile(t,i){const s=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,o=r?{image:r.image.clone()}:null,n=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:o,scope:this.scope,pixelRatio:e.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:n,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.sendCancelable(s,a,{},(e,r)=>n&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===s),void i(null))));}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.aborted=!0;}unloadTile(e,t){this.actor.notify("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(e){this._pendingLoad&&this._pendingLoad.abort();}serialize(){return {...this._options,type:this.type,data:this._data}}hasTransition(){return !1}},video:class extends nr{constructor(e,t,i,s){super(e,t,i,s),this.roundZoom=!0,this.type="video",this.options=t;}async load(){this._loaded=!1;const t=this.options,i=new AbortController;this._imageRequest=i;try{const s=await Promise.all(t.urls.map(async t=>(await this.map._requestManager.transformRequest(t,e.R.Source,i.signal)).url));if(i.signal.aborted)return;this.urls=s;const r=await e.cw(s);if(i.signal.aborted)return;this._imageRequest=null,this.video=r,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint();}),this.map&&this.video.play(),this._finishLoading();}catch(t){if(i.signal.aborted)return;this.fire(new e.f(t));}finally{this._loaded=!0;}}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.f(new ce(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.options.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:nr,canvas:class extends nr{constructor(t,i,s,r){super(t,i,s,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.f(new ce(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.f(new ce(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.f(new ce(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.f(new ce(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.f(new ce(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}async load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.f(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(e){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.co||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"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}},custom:class extends e.E{constructor(t,i,s,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=s,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.f(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.f(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new e.cf(this._implementation.bounds,this.minzoom,this.maxzoom));const o=i;o.update=this._update.bind(this),o.clearTiles=this._clearTiles.bind(this),o.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.cb(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.cb(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.h("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.h("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:s}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:s})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e,t){const{x:i,y:s,z:r}=e.tileID.canonical,o=new AbortController;e.request=o;try{const n=await this._implementation.loadTile({x:i,y:s,z:r},{signal:o.signal});if(delete e.request,e.aborted)return e.state="unloaded",t(null);if(void 0===n)return e.state="errored",t(null);if(null===n)return this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null);if(!function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(n))return e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`));this.loadTileData(e,n),e.state="loaded",t(null);}catch(i){if(o.signal.aborted)return;e.state="errored",t(i);}}loadTileData(e,t){e.setTexture(t,this.map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:s}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:s});}i&&i();}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),t&&t();}hasTransition(){return !1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.m(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.h("data",{dataType:"source",sourceDataType:"content"}));}}},lr=function(t,i,s,r){const o=cr(i.type);if(!o)throw new Error(`Unknown source type "${i.type}"`);const n=new o(t,i,s,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return e.aV(["load","abort","unload","serialize","prepare"],n),n},cr=function(e){return Object.hasOwn(ar,e)?ar[e]:void 0};function hr([t,i],s,r,{scaled:o=!0}={}){const{tileSize:n,buffer:a}=r,{x:l,y:c,z:h}=s;if(!isFinite(l)||!isFinite(c)||!isFinite(h))throw new Error("Invalid MRT header");const d=2**h,u=d*e.a7(t),p=d*e.a8(i);return function([e,t],i,{scaled:s=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:o,buffer:n,offset:a,scale:l,dimension:c}=i;if(e<-n||e>o+n||t<-n||t>o+n)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${n}`);const h=(t+n)*(o+2*n)+(e+n);if(4294967295===new Uint32Array(r.buffer)[h])return null;let d=[];d=s?[]:new(0,i.data.constructor)(c);for(let e=0;e<c;e++)d[e]=Math.round(1e12*(r[c*h+e]*l+a))/1e12;return d}([Math.min(Math.max(-a,Math.floor((u-l)*n)),n-1+a),Math.min(Math.max(-a,Math.floor((p-c)*n)),n-1+a)],r,{scaled:o})}e.cA.setPbf(e.cB);class dr extends fs{constructor(e,t,i,s,r){super(e,t,i,s,r),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map;}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(e){return this._mrt&&this._mrt.getLayer(e)}setTexturePerLayer(t,i,s){const r=s.context,o=r.gl;let n=this.texturePerLayer.get(t)||s.getTileTexture(i.width);n&&n instanceof e.T?n.update(i,{premultiply:!1}):n=new e.T(r,i,o.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,n);}flushQueues(e){const t=this._workQueuePerLayer.get(e)||[],i=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();for(;i.length;)i.pop()();}flushAllQueues(){for(const e of this._workQueuePerLayer.keys()){const t=this._workQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}for(const e of this._fetchQueuePerLayer.keys()){const t=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}}fetchHeader(t=16384,i){const s=this._mrt=new e.cA(30),r={...this.requestParams,headers:{Range:"bytes=0-"+(t-1)}};this.entireBuffer=null;const o=new AbortController;return this.request=o,e.cC(r,o.signal).then(({data:e,headers:r})=>{try{const o=s.getHeaderLength(e);if(o>t)return void(this.request=this.fetchHeader(o,i));s.parseHeader(e),this._isHeaderLoaded=!0;let n=0;for(const e of Object.values(s.layers))n=Math.max(n,e.dataIndex.at(-1).lastByte);e.byteLength>=n&&(this.entireBuffer=e),i(null,this.entireBuffer||e,r);}catch(e){i(e);}}).catch(e=>{o.signal.aborted||i(e);}),this.request}fetchBandForRender(e,t,i,s){this.fetchBand(e,t,i,r=>{if(r)return void s(r);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);s(null,o?o.img:null);});}fetchBand(t,i,s,r){const o=this._mrt;if(!this._isHeaderLoaded||!o)return void r(new Error("Tile header is not ready"));const n=this.actor;if(!n)return void r(new Error("Can't fetch tile band without an actor"));let a;const l=e.m(String(s),e.m(this.tileID.key,t));let c=this._taskQueue.get(l);c?c.add(r):(c=new Set,c.add(r),this._taskQueue.set(l,c));const h=(e,t)=>{a.complete(e,t),e?r(e):(c.forEach(e=>e(null,t)),this._taskQueue.delete(l));},d=(e,t)=>{if(e)return r(e);let s,o=!1;if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{o=!0,s&&s.abort(),a.cancel();}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e);}const l=()=>{o||(s=n.sendCancelable("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:a},{},h));};void 0!==this.workerReady?this.workerReady.then(l).catch(e=>r(e)):l();};let u;try{u=o.getLayer(t);}catch(e){if("reloading"===this.state)return;throw e}if(!u)return void r(new Error(`Unknown sourceLayer "${t}"`));if(u.hasDataForBand(s))return c.forEach(e=>e(null,null)),void this._taskQueue.delete(l);const p=u.getDataRange([s]);if(a=o.createDecodingTask(p),!a||a.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(p.firstByte,p.lastByte+1));else {const t={...this.requestParams,headers:{Range:`bytes=${p.firstByte}-${p.lastByte}`}},s=new AbortController;if(e.cC(t,s.signal).then(({data:e})=>d(null,e)).catch(e=>{s.signal.aborted||d(e);}),null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{s.abort(),a.cancel();}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e);}}}updateNeeded(e,t){return (!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,s){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(s)||!r.hasDataForBand(s))return;const{bytes:o,tileSize:n,buffer:a,offset:l,scale:c}=r.getBandView(s),h=n+2*a,d=new e.b({width:h,height:h},o),u=this.texturePerLayer.get(i);u&&u instanceof e.T&&u.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:s,img:d,buffer:a,offset:l,tileSize:n,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]});}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1;}}us=(e,t,i,s,r)=>new dr(e,t,i,s,r);const ur={RasterArrayTileSource:class extends ir{get partial(){return !this.map.style.imageManager.hasImageProviderForSource(this.id,this.scope)}constructor(e,t,i,s){super(e,t,i,s),this.type="raster-array",this.maxzoom=22,this._loadTilePending={},this._loadTileLoaded={},this._options={type:"raster-array",...t};}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}async loadTile(t,i){const s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.source=this.id,t.scope=this.scope,void 0===this._workerReady&&(this._workerReady=this.dispatcher.send("ensureRasterArraySource",void 0).then(()=>{}),this._workerReady.catch(()=>{})),t.workerReady=this._workerReady,t.actor||(t.actor=this.dispatcher.getActor());const r=new AbortController;t.request=r;const o=(s,r,o)=>{if(delete t.request,t.aborted)return i(null);if(s)return t.state="errored",i(s);if(this.map._refreshExpiredTiles&&r&&t.setExpiryData(e.ci(o)),this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r;}i(null);};try{const n=await this.map._requestManager.transformRequest(s,e.R.Tile,r.signal);if(r.signal.aborted)return i(null);t.requestParams=n;const a={request:n,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.request=this.partial?t.fetchHeader(void 0,(e,t,i)=>{o(e,t,i);}):t.actor.sendCancelable("loadTile",a,{},(e,t)=>e?o(e):t?void o(null,t.mrt,t.headers):o(null,null));}catch(e){if(r.signal.aborted)return i(null);t.state="errored",i(e);}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e);}else e.destroy();}prepareTile(t,i,s,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,s,r,(i,r)=>{i?(t.state="errored",this.fire(new e.f(i))):r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(s,r,this.map.painter),t.state="loaded"),this.triggerRepaint(t);}));}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,s=i&&i.bands&&i.bands;return s?s[0]:0}getTextureDescriptor(t,i,s){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let o=null;i instanceof e.cx?o=i.paint.get("raster-array-band"):i instanceof e.cy&&(o=i.paint.get("raster-particle-array-band"));const n=o||this.getInitialBand(r);if(null!=n)if(t.textureDescriptorPerLayer.get(i.id)){if(!t.updateNeeded(i.id,n)||s)return {...t.textureDescriptorPerLayer.get(i.id),texture:t.texturePerLayer.get(i.id)}}else this.prepareTile(t,r,i.id,n);}getImages(t,i){const s=new Map;for(const r of t)for(const t of i){const[i,o]=t.split("/"),n=r.getLayer(i);if(!n)continue;if(!n.hasBand(o)||!n.hasDataForBand(o))continue;const{bytes:a,tileSize:l,buffer:c}=n.getBandView(o),h=l+2*c,d={data:new e.b({width:h,height:h},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};s.set(t,d);}return s}queryRasterArrayValueByBandId(t,i,s){const r=i._mrt;return new Promise(o=>{const n={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(s.layerName&&l!==s.layerName)continue;const h={};n[l]=h;for(const{bands:d}of c.dataIndex)for(const u of d)s.bands&&!s.bands.includes(u)||(a.add(e.m(l,u)),i.fetchBand(l,null,u,i=>{e.e.frame(()=>{h[u]=i?null:hr([t.lng,t.lat],r,c.getBandView(u)),a.delete(e.m(l,u)),0===a.size&&o(n);});}));}0===a.size&&o(n);})}_loadTileForQuery(e){if(this._loadTileLoaded[e.uid])return Promise.resolve(e._mrt);if(e.uid in this._loadTilePending)return this._loadTilePending[e.uid];const t=this._fetchTileForQuery(e);return this._loadTilePending[e.uid]=t,t}async _fetchTileForQuery(t){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);try{const s={request:await this.map._requestManager.transformRequest(i,e.R.Tile),uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},r=await t.actor.send("loadTile",s);if(!r)return null;const o=r.mrt;return this.map._refreshExpiredTiles&&t.setExpiryData(e.ci(r.headers)),t._mrt=o,t._isHeaderLoaded=!0,t.state="loaded",this._loadTileLoaded[t.uid]=!0,o}finally{delete this._loadTilePending[t.uid];}}async queryRasterArrayValueByAllBands(e,t,i){return await this._loadTileForQuery(t)?this.queryRasterArrayValueByBandId(e,t,i):null}queryRasterArrayValue(t,i){const s=e.cz.convert(t),r=this.findLoadedParent(s);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(s,r,i):this.queryRasterArrayValueByAllBands(s,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.bS.fromLngLat(t,this.map.transform.tileSize),s=this.maxzoom+1,r=1<<s,o=Math.floor(i.x),n=Math.floor((i.x-o)*r),a=Math.floor(i.y*r);if(n<0||n>=r||a<0||a>=r)return null;const l=this.map.style.getSourceCache(this.id),c=new e.bP(s,o,s,n,a);return l.findLoadedParent(c,this.minzoom)}}},pr=ur,fr={model:()=>hi().then(()=>ci.ModelSource),"batched-model":()=>hi().then(()=>ci.Tiled3dModelSource),"raster-array":()=>async function(){return Promise.resolve()}().then(()=>pr.RasterArrayTileSource)};class mr extends e.E{constructor(e,t,i,s){super(),this.id=e,this.type=t.type,this._options=t,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.setEventedParent(s);}hasTransition(){return !1}loaded(){return !1}onAdd(e){}onRemove(e){}loadTile(e,t){}serialize(){return this._options}}function _r(e,t,i=""){return `${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return `layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return `featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function gr(e,t,i,s=""){if(e.uniqueFeatureID){const r=_r(e,t,s);if(i.has(r))return !0;i.add(r);}return !1}function yr(e,t,i,s,r=!1,o=void 0){const n=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,r);a.sort(xr);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,s,n,r,o);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a});}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,s);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i});}}return 0===l.length?{}:function(e){const t={},i={};for(const s of e){const e=s.queryResults,r=s.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const s=e[i],r=o[i]=o[i]||{},n=t[i]=t[i]||[];for(const e of s)r[e.featureIndex]||(r[e.featureIndex]=!0,n.push(e));}}return t}(l)}function vr(e,t,i,s,r,o){const n={},a=s.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(xr);for(const e of l){const s=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in s){const i=n[t]=n[t]||[],r=s[t];r.sort((t,i)=>{const s=e.featureSortOrder;if(s){const e=s.indexOf(t.featureIndex);return s.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e);}}return n}function br(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),s=[],r={};for(let e=0;e<i.length;e++){const o=i[e],n=o.tileID.canonical.key;r[n]||(r[n]=!0,o.querySourceFeatures(s,t));}return s}function xr(e,t){const i=e.tileID,s=t.tileID;return i.overscaledZ-s.overscaledZ||i.canonical.y-s.canonical.y||i.wrap-s.wrap||i.canonical.x-s.canonical.x}class wr{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[];}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const i in this.style._mergedLayers){const s=this.style._mergedLayers[i];if("fill-extrusion"===s.type||"building"===s.type)this.layers.push({layer:s,visible:e,visibilityChanged:t});else if("model"===s.type){const i=this.style.getLayerSource(s);i&&"batched-model"===i.type&&this.layers.push({layer:s,visible:e,visibilityChanged:t});}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let s=!1;"fill-extrusion"===i.type?s=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"building"===i.type?s=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(s=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!s&&t.visible,t.visible=s;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,s=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let o=s?s.getTile(t):null;if(!o&&s)for(const e in s._tiles){const i=s._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){o=i;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let s=0;s<e.symbolInstances.length;s++){const r=e.symbolInstances.get(s),o=r.zOffset,n=this._getHeightAtTileOffset(t,r.tileAnchorX,r.tileAnchorY);r.zOffset=n!==Number.NEGATIVE_INFINITY?n:o,i||o===r.zOffset||(i=!0),e.hasAnyZOffset||0===r.zOffset||(e.hasAnyZOffset=!0);}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}hasLayerForSourceCache(e){for(const{layer:t}of this.layers){const i=this.style.getLayerSourceCache(t);if(i&&i.id===e)return !0}return !1}_mapCoordToOverlappingTile(t,i,s,r){let o=i,n=s;if(t.canonical.z!==r.canonical.z){const a=r.canonical,l=1/(1<<t.canonical.z-a.z);o=(i+t.canonical.x*e.a2)*l-a.x*e.a2|0,n=(s+t.canonical.y*e.a2)*l-a.y*e.a2|0;}return {tileX:o,tileY:n}}_getHeightAtTileOffset(e,t,i){let s,r;for(let o=0;o<this.layers.length;++o){const n=this.layers[o].layer;if("fill-extrusion"!==n.type&&"building"!==n.type)continue;const{bucket:a,tileID:l,verticalScale:c}=this.currentBuildingBuckets[o];if(!a)continue;const{tileX:h,tileY:d}=this._mapCoordToOverlappingTile(e,t,i,l),u=a.getHeightAtTileCoord(h,d);u&&void 0!==u.height&&(u.hidden?s=u.height:r=Math.max(u.height*c,r||0));}if(void 0!==r)return r;for(let r=0;r<this.layers.length;++r){const o=this.layers[r];if("model"!==o.layer.type||!o.visible)continue;const{bucket:n,tileID:a}=this.currentBuildingBuckets[r];if(!n)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,a),h=n.getHeightAtTileCoord(l,c);if(h&&!h.hidden)return void 0===h.height&&void 0!==s?Math.min(h.maxHeight,s)*h.verticalScale:h.height?h.height*h.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let Tr;function Sr(){return Tr||(Tr=new Jt),Tr}function Cr(t,i){const s={},r=t,o=i,n=s;for(const e in r)"ref"!==e&&(n[e]=r[e]);return e.cD.forEach(e=>{e in o&&(n[e]=o[e]);}),s}function Er(e){e=e.slice();const t=Object.create(null);for(const i of e)t[i.id]=i;for(let i=0;i<e.length;i++){const s=e[i];if(s&&"ref"in s){const r=t[s.ref];r&&(e[i]=Cr(s,r));}}return e}class Ir{constructor(e,t,i,s){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):s&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Dr{constructor(e,t,i,s,r,o=!1){this.text=new Ir(e?e.text:null,t,i,r),this.icon=new Ir(e?e.icon:null,t,s,r),this.clipped=o;}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Pr{constructor(e,t,i,s=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=s;}}class Lr{constructor(){this.invProjMatrix=e.Y(),this.viewportMatrix=e.Y(),this.circles=[];}}class Rr{constructor(e,t,i,s,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=s,this.tileID=r;}}class Ar{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 Mr(t,i,s,r,o){const{horizontalAlign:n,verticalAlign:a}=e.cM(t),l=-(n-.5)*i,c=-(a-.5)*s,h=e.cN(t,r);return new e.P(l+h[0]*o,c+h[1]*o)}function Fr(t,i,s,r,o){const n=new e.P(t,i);return s&&n._rotate(r?o:-o),n}function Or(t,i,s,r){const{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=s,h=e.cO(i),d=r===e.cL.vertical?l:"left"===h?o:"center"===h?n:"right"===h?a:-1;o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=d>=0&&o!==d?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=d>=0&&n!==d?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=d>=0&&a!==d?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:c);}function Br(t,i,s){const r=i===e.cL.horizontal||i===e.cL.horizontalOnly?i:0,o=i===e.cL.vertical?i:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=s,h=t.text.placedSymbolArray;n>=0&&(h.get(n).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=o);}class kr{constructor(e,t,i,s,r,o,n,a){this.transform=e.clone(),this.projection=e.projection.name,this.algorithm=s,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,o,a),this.buildingIndex=n,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ar(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0;}getBucketParts(t,i,s,r,o=1){const n=s.getBucket(i),a=s.latestFeatureIndex;if(!n||!a||i.fqid!==n.layerIds[0])return;const l=n.layers[0].layout,c=n.layers[0].paint,h=s.collisionBoxArray,d=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),u=s.tileSize/e.a2,p=s.tileID.toUnwrapped();this.transform.setProjection(n.projection);const f=(m=s.tileID,_=n.getProjection(),g=this.transform,_.name===this.projection?g.calculateProjMatrix(m.toUnwrapped()):gt(g,_,m));var m,_,g;const y="map"===l.get("text-pitch-alignment"),v="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const b=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(s),S=e.cE(f,s.tileID.canonical,y,v,this.transform,n.getProjection(),T);let C=null;const E=n.getProjection().createInversionMatrix(this.transform,s.tileID.canonical);if(y){const t=e.cF(f,s.tileID.canonical,y,v,this.transform,n.getProjection(),T);C=e.X([],this.transform.labelPlaneMatrix,t);}let I=null;b&&s.latestFeatureIndex&&(I={unwrappedTileID:p,dynamicFilter:b,dynamicFilterNeedsFeature:x,needGeometry:w}),this.retainedQueryData[n.bucketInstanceId]=new Rr(n.bucketInstanceId,a,n.sourceLayerIndex,n.index,s.tileID);const[D,P]=n.layers[0].layout.get("text-size-scale-range"),L=e.b0(o,D,P),[R,A]=l.get("icon-size-scale-range"),M=e.b0(o,R,A),F={bucket:n,layout:l,paint:c,posMatrix:f,invMatrix:E,mercatorCenter:[e.a7(this.transform.center.lng),e.a8(this.transform.center.lat)],textLabelPlaneMatrix:S,labelToScreenMatrix:C,clippingData:I,scale:d,textPixelRatio:u,holdingForFade:s.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.cG(n.textSizeData,this.transform.zoom,L),partiallyEvaluatedIconSize:e.cG(n.iconSizeData,this.transform.zoom,M),collisionGroup:this.collisionGroups.get(n.sourceID),latestFeatureIndex:s.latestFeatureIndex};if(r)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:s,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:s,symbolInstanceEnd:r,parameters:F});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:F});}placeLayerBucketPart(e,t,i,s=1){this.algorithm.placeLayerBucketPart(this,e,t,i,s);}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 s=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},n=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new Dr(o,s,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Dr(null,s,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Dr(t,s,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||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 n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(t,i,s,r,o=!1,n=1){r&&(this.lastReplacementSourceUpdateTime=r.updateTime);const a=new Set;for(const l of i){const i=l.getBucket(t);if(i&&l.latestFeatureIndex&&t.fqid===i.layerIds[0]&&(this.updateBucketOpacities(i,a,l,l.collisionBoxArray,s,r,l.tileID,t.scope),"offset"===i.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(i,l.tileID),"road"===i.elevationType&&i.hdExt&&i.hdExt.updateRoadElevation(i,l.tileID.canonical),i.updateZOffset(),o&&l.collisionBoxArray)){const t=i.layers[0].layout,[s,r]=t.get("text-size-scale-range"),[o,a]=t.get("icon-size-scale-range"),c=e.b0(n,s,r),h=e.b0(n,o,a);i.updateCollisionDebugBuffers(this.transform.zoom,l.collisionBoxArray,c,h);}}}updateBucketOpacities(t,i,s,r,o,n,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,d=!!t.layers[0].dynamicFilter(),u=new Dr(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),_="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),y=h.get("symbol-z-offset"),v="sea"===c.get("symbol-elevation-reference"),b=!y.isConstant(),x=new Dr(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let s=0;s<t/4;s++)e.opacityVertexArray.emplaceBack(i);};let T=0;n&&t.updateReplacement(a,n),this.collisionIndex.clearClippedSymbolsForBucket(t.bucketInstanceId);for(let r=0;r<t.symbolInstances.length;r++){const c=t.symbolInstances.get(r),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:p,crossTileID:f,numIconVertices:S,tileAnchorX:C,tileAnchorY:E}=c;let I=null;const D=this.retainedQueryData[t.bucketInstanceId];b&&c&&D&&(I=s.latestFeatureIndex.loadFeature({featureIndex:c.featureIndex,bucketIndex:D.bucketIndex,sourceLayerIndex:D.sourceLayerIndex,layoutVertexArrayOffset:0}));const P=y.evaluate(I,{}),L=i.has(f);let R=this.opacities[f];L?R=u:R||(R=x,this.opacities[f]=R),i.add(f);const A=h>0||p>0,M=S>0,F=this.placedOrientations[f],O=F===e.cL.vertical,B=F===e.cL.horizontal||F===e.cL.horizontalOnly;!A&&!M||R.isHidden()||T++;let k=!1;if((A||M)&&n)for(const i of t.activeReplacements){if(e.cH(i,o,e.cI.Symbol,l))continue;if(i.min.x>C||C>i.max.x||i.min.y>E||E>i.max.y)continue;const t=e.cJ(C,E,a.canonical,i.footprintTileId.canonical);if(k=e.cK(t,i.footprint),k)break}if(k&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,c.featureIndex),A){const e=k?Hr:$r(R.text);w(t.text,h,O?Hr:e),w(t.text,p,B?Hr:e);const i=R.text.isHidden(),{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:n}=c,a=t.text.placedSymbolArray,l=i||O?1:0;s>=0&&(a.get(s).hidden=l),r>=0&&(a.get(r).hidden=l),o>=0&&(a.get(o).hidden=l),n>=0&&(a.get(n).hidden=i||B?1:0);const d=this.variableOffsets[f];d&&Or(t,d.anchor,c,F);const u=this.placedOrientations[f];u&&(Or(t,"left",c,u),Br(t,u,c));}if(M){const e=k?Hr:$r(R.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:s}=c,r=t.icon.placedSymbolArray,o=R.icon.isHidden()?1:0;i>=0&&(w(t.icon,S,O?Hr:e),r.get(i).hidden=o),s>=0&&(w(t.icon,c.numVerticalIconVertices,B?Hr:e),r.get(s).hidden=o);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let s=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(s=Mr(e.anchor,e.width,e.height,e.textOffset,e.textScale),_&&s._rotate(g?this.transform.angle:-this.transform.angle)):r=!1;}d&&(r=!R.clipped),i.textBox&&zr(t.textCollisionBox.collisionVertexArray,R.text.placed,!r||O,P,v,s.x,s.y),i.verticalTextBox&&zr(t.textCollisionBox.collisionVertexArray,R.text.placed,!r||B,P,v,s.x,s.y);}const o=r&&Boolean(!B&&i.verticalIconBox);i.iconBox&&zr(t.iconCollisionBox.collisionVertexArray,R.icon.placed,o,P,v,c.hasIconTextFit?s.x:0,c.hasIconTextFit?s.y:0),i.verticalIconBox&&zr(t.iconCollisionBox.collisionVertexArray,R.icon.placed,!o,P,v,c.hasIconTextFit?s.x:0,c.hasIconTextFit?s.y:0);}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.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 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}isStale(){return this.stale}setStale(){this.stale=!0;}}function zr(e,t,i,s,r,o,n){e.emplaceBack(t?1:0,i?1:0,o||0,n||0,s,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,n||0,s,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,n||0,s,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,n||0,s,r?1:0);}const Ur=Math.pow(2,25),Nr=Math.pow(2,24),jr=Math.pow(2,17),Vr=Math.pow(2,16),Gr=Math.pow(2,9),qr=Math.pow(2,8),Zr=Math.pow(2,1);function $r(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*Ur+t*Nr+i*jr+t*Vr+i*Gr+t*qr+i*Zr+t}const Hr=0;class Wr{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.at(-1),this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding;}lerp(t){if(1===this.points.length)return this.points[0];t=e.b0(t,0,1);let i=1,s=this._distances[i];const r=t*this.paddedLength+this.padding;for(;s<r&&i<this._distances.length;)s=this._distances[++i];const o=i-1,n=this._distances[o],a=s-n,l=a>0?(r-n)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}const Xr=100;class Kr{constructor(e,t){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(e,t);}reset(t,i){const s=t.width+200,r=t.height+200;s!==this.gridRightBoundary||r!==this.gridBottomBoundary?(this.grid=new e.cP(s,r,25),this.ignoredGrid=new e.cP(s,r,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=t,this.fogState=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Xr,this.screenBottomBoundary=t.height+Xr,this.gridRightBoundary=s,this.gridBottomBoundary=r,this.clippedSymbols.clear();}clearClippedSymbolsForBucket(e){this.clippedSymbols.delete(e);}markSymbolAsClipped(e,t){let i=this.clippedSymbols.get(e);i||(i=new Set,this.clippedSymbols.set(e,i)),i.add(t);}placeCollisionBox(t,i,s,r,o,n,a,l,c,h,d){let u=s.projectedAnchorX,p=s.projectedAnchorY,f=s.projectedAnchorZ;const m=s.tileAnchorX,_=s.tileAnchorY,g=s.elevation,y=s.tileID,v=t.getProjection();if(g&&y){const[e,t,i]=v.upVector(y.canonical,s.tileAnchorX,s.tileAnchorY),r=v.upVectorScale(y.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;u+=e*g*r,p+=t*g*r,f+=i*g*r;}const b="globe"===t.projection.name,x="globe"===t.projection.name?e.S(this.transform.zoom):0;if(y&&b&&x<1&&!n){const t=1<<y.canonical.z,i=e.cQ(m,_);e.cR(i,i,1/e.a2),e.cS(i,i,e.cQ(y.canonical.x,y.canonical.y)),e.cR(i,i,1/t),e.cT(i,i,e.cQ(r[0],r[1])),i[0]=e.cU(i[0],-.5,.5),e.cR(i,i,e.a2);const s=e.cV(i[0],i[1],e.a2/(2*Math.PI),1);e.c7(s,s,o),u=e.al(u,s[0],x),p=e.al(p,s[1],x),f=e.al(f,s[2],x);}const w=this.projectAndGetPerspectiveRatio(h,u,p,f,s.tileID,"globe"===v.name||!!g||this.transform.pitch>0,v),T=c*w.perspectiveRatio,S=(s.x1*i+a.x-s.padding)*T+w.point.x,C=(s.y1*i+a.y-s.padding)*T+w.point.y,E=(s.x2*i+a.x+s.padding)*T+w.point.x,I=(s.y2*i+a.y+s.padding)*T+w.point.y,D=w.perspectiveRatio<=.55||w.occluded;return !this.isInsideGrid(S,C,E,I)||!l&&this.grid.hitTest(S,C,E,I,d)||D?{box:[],offscreen:!1,occluded:w.occluded}:{box:[S,C,E,I],offscreen:this.isOffscreen(S,C,E,I),occluded:!1}}placeCollisionCircles(t,i,s,r,o,n,a,l,c,h,d,u,p,f,m,_){const g=[],y=this.transform.elevation,v=t.getProjection(),b="road"===t.elevationType,x=!!y||b,w=e.cW.getAtTileOffsetFunc(_,this.transform.center.lat,this.transform.worldSize,v),T=new e.P(s.tileAnchorX,s.tileAnchorY),S=new e.P(s.tileAnchorX,s.tileAnchorY);let{x:C,y:E,z:I}=v.projectTilePoint(S.x,S.y,_.canonical),D=null;if(x){D=b&&t.hdExt?t.hdExt.makeRoadSymbolElevationParams(t,t.text,r,_,w,y,v,this.transform.center.lat,this.transform.worldSize):{getElevation:w,elevation:y,elevationFeature:null};const[e,i,s]=D.getElevation(T,y,D.elevationFeature);C+=e,E+=i,I+=s;}const P="globe"===v.name,L=this.projectAndGetPerspectiveRatio(l,C,E,I,_,P||!!y||this.transform.pitch>0,v),{perspectiveRatio:R}=L,A=(u?a/R:a*R)/e.d1,M=e.cX(C,E,I,c),F=s.lineOffsetX*A,O=s.lineOffsetY*A,B=e.au(t.layers[0].layout.get("text-max-angle")),k=Math.cos(B),z=L.signedDistanceFromCamera>0?e.cY(A,n,F,O,b&&1===s.flipState,M,S,s,o,c,{},x&&!u?D:null,u&&x,v,_,u,k):null;let U=!1,N=!1,j=!0;if(z&&!L.occluded){const t=.5*f*R+m,s=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Wr,{first:n,last:a}=z,l=n.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(n.path[e]);for(let e=1;e<a.path.length;e++)c.push(a.path[e]);const u=2.5*t;h&&(c=c.map(([t,i,s],r)=>(x&&!P&&(s=D.getElevation(r<l-1?n.tilePath[l-1-r]:a.tilePath[r-l+2],y,D.elevationFeature)[2]),e.cX(t,i,s,h))),c.some(e=>e[3]<=0)&&(c=[]));let _=[];if(c.length>0){let t=1/0,i=-1/0,o=1/0,n=-1/0;for(const e of c)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),n=Math.max(n,e[1]);i>=s.x&&t<=r.x&&n>=s.y&&o<=r.y&&(_=[c.map(t=>new e.P(t[0],t[1]))],(t<s.x||i>r.x||o<s.y||n>r.y)&&(_=e.cZ(_,s.x,s.y,r.x,r.y)));}for(const e of _){o.reset(e,.25*t);let s=0;s=o.length<=.5*t?1:Math.ceil(o.paddedLength/u)+1;for(let e=0;e<s;e++){const r=e/Math.max(s-1,1),n=o.lerp(r),a=n.x+Xr,l=n.y+Xr;g.push(a,l,t,0);const c=a-t,h=l-t,u=a+t,f=l+t;if(j=j&&this.isOffscreen(c,h,u,f),N=N||this.isInsideGrid(c,h,u,f),!i&&this.grid.hitTestCircle(a,l,t,p)&&(U=!0,!d))return {circles:[],offscreen:!1,collisionDetected:U,occluded:!1}}}}return {circles:!d&&U||!N?[]:g,offscreen:j,collisionDetected:U,occluded:L.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let s=1/0,r=1/0,o=-1/0,n=-1/0;for(const a of t){const t=new e.P(a.x+Xr,a.y+Xr);s=Math.min(s,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),n=Math.max(n,t.y),i.push(t);}const a=this.grid.query(s,r,o,n).concat(this.ignoredGrid.query(s,r,o,n)),l={},c={};for(const t of a){const s=t.key;if(void 0===l[s.bucketInstanceId]&&(l[s.bucketInstanceId]={}),l[s.bucketInstanceId][s.featureIndex])continue;const r=this.clippedSymbols.get(s.bucketInstanceId);if(r&&r.has(s.featureIndex))continue;const o=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.aT(i,o)&&(l[s.bucketInstanceId][s.featureIndex]=!0,void 0===c[s.bucketInstanceId]&&(c[s.bucketInstanceId]=[]),c[s.bucketInstanceId].push(s.featureIndex));}return c}insertCollisionBox(e,t,i,s,r){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:s,collisionGroupID:r},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,s,r){const o=t?this.ignoredGrid:this.grid,n={bucketInstanceId:i,featureIndex:s,collisionGroupID:r};for(let t=0;t<e.length;t+=4)o.insertCircle(n,e[t],e[t+1],e[t+2]);}projectAndGetPerspectiveRatio(t,i,s,r,o,n,a){const l=[i,s,r,1];let c=!1;r||this.transform.pitch>0?(e.c7(l,l,t),this.fogState&&o&&"globe"!==a.name&&(c=e.c_(this.fogState,i,s,r,o.toUnwrapped(),this.transform)>e.d2)):e.c$(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Xr,(-l[1]/h+1)/2*this.transform.height+Xr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:n&&l[2]>h||c}}isOffscreen(e,t,i,s){return i<Xr||e>=this.screenRightBoundary||s<Xr||t>this.screenBottomBoundary}isInsideGrid(e,t,i,s){return i>=0&&e<this.gridRightBoundary&&s>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.d0([]);return e.bM(t,t,[-100,-100,0]),t}}const Yr={default:new class{createCollisionDetector(e,t,i){return i instanceof Kr?(i.reset(e,t),i):new Kr(e,t)}shouldPause(e){return e>2}placeLayerBucketPart(t,i,s,r,o=1){const{bucket:n,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:d,clippingData:u,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:_,collisionBoxArray:g,partiallyEvaluatedTextSize:y,partiallyEvaluatedIconSize:v,collisionGroup:b,latestFeatureIndex:x}=i.parameters,w=a.get("text-optional"),T=a.get("icon-optional"),S=a.get("text-allow-overlap"),C=a.get("icon-allow-overlap"),E="map"===a.get("text-rotation-alignment"),I="map"===a.get("icon-rotation-alignment"),D="map"===a.get("text-pitch-alignment"),P=l.get("symbol-z-offset"),L="sea"===a.get("symbol-elevation-reference"),R=a.get("symbol-placement"),A=a.get("text-variable-anchor"),M=E&&"point"!==R,F=I&&"point"!==R,O=A&&n.hasTextData(),B=n.hasIconTextFit()&&O&&n.hasIconData();t.transform.setProjection(n.projection);const k=O||M,z=F||B;let U=S&&(C||!n.hasIconData()||T),N=C&&(S||!n.hasTextData()||w);const j=!P.isConstant();!n.collisionArrays&&g&&n.deserializeCollisionBoxes(g);const V=(i,o,l)=>{const{crossTileID:g,numVerticalGlyphVertices:I}=i;let R=null;if(u&&u.dynamicFilterNeedsFeature||j){const s=t.retainedQueryData[n.bucketInstanceId],r=x.loadFeature({featureIndex:i.featureIndex,bucketIndex:s.bucketIndex,sourceLayerIndex:s.sourceLayerIndex,layoutVertexArrayOffset:0}),o=r.properties?r.properties.worldview:null;if(n.localizable&&n.worldview&&"string"==typeof o)if("all"===o)r.properties.$localized=!0;else {if(!o.split(",").includes(n.worldview))return;r.properties.$localized=!0,r.properties.worldview=n.worldview;}R=u&&u.needGeometry?e.bw(r,!0):r;}if(u&&!(0,u.dynamicFilter)({zoom:t.transform.zoom,pitch:t.transform.pitch,worldview:n.worldview},R,t.retainedQueryData[n.bucketInstanceId].tileID.canonical,new e.P(i.tileAnchorX,i.tileAnchorY),t.transform.calculateDistanceTileData(u.unwrappedTileID)))return t.placements[g]=new Pr(!1,!1,!1,!0),void s.add(g);const M=P.evaluate(R,{});if((i.zOffset||0)+(M||0)>0&&t.frontCutoffStart>0){const r=2*t.frontCutoffStart-1,o=[i.tileAnchorX,i.tileAnchorY,0,1],n=e.c7(e.d3(),o,c);if(n[1]/n[3]<r)return t.placements[g]=new Pr(!1,!1,!1,!0),void s.add(g)}if(s.has(g))return;if(_)return void(t.placements[g]=new Pr(!1,!1,!1));let F=!1,O=!1,B=!0,V=!1,G=!1,q=null,Z={box:null,offscreen:null,occluded:null},$={box:null},H=null,W=null,X=null,K=0,Y=0,Q=0;l.textFeatureIndex?K=l.textFeatureIndex:i.useRuntimeCollisionCircles&&(K=i.featureIndex),l.verticalTextFeatureIndex&&(Y=l.verticalTextFeatureIndex);const J=s=>{s.tileID=t.retainedQueryData[n.bucketInstanceId].tileID;const r=t.transform.elevation;if("road"===n.elevationType)s.elevation=L?M:M+e.cW.getAtTileOffset(s.tileID,new e.P(s.tileAnchorX,s.tileAnchorY),r,null);else {const t=n.hdExt?n.hdExt.elevationFeatures[i.elevationFeatureIndex]:void 0;s.elevation=L?M:M+e.cW.getAtTileOffset(s.tileID,new e.P(s.tileAnchorX,s.tileAnchorY),r,t);}s.elevation+=i.zOffset;},ee=l.textBox;if(ee){J(ee);const s=s=>{let r=e.cL.horizontal;if(n.allowVerticalPlacement&&!s&&t.prevPlacement){const e=t.prevPlacement.placedOrientations[g];e&&(t.placedOrientations[g]=e,r=e,Br(n,r,i));}return r},r=(t,i)=>{if(n.allowVerticalPlacement&&I>0&&l.verticalTextBox){for(const s of n.writingModes)if(s===e.cL.vertical?(Z=i(),$=Z):Z=t(),Z&&Z.box&&Z.box.length)break}else Z=t();};if(A){let a=A;if(t.prevPlacement&&t.prevPlacement.variableOffsets[g]){const e=t.prevPlacement.variableOffsets[g];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor));}const h=(e,s,r)=>{const l=n.getSymbolInstanceTextSize(y,i,t.transform.zoom,o),h=(e.x2-e.x1)*l+2*e.padding,d=(e.y2-e.y1)*l+2*e.padding,u=i.hasIconTextFit&&!C?s:null;u&&J(u);let _={box:[],offscreen:!1,occluded:!1};const g=S?2*a.length:a.length;for(let s=0;s<g;++s){const g=this.attemptAnchorPlacement(t,a[s%a.length],e,f,m,k,h,d,l,E,D,p,c,b,s>=a.length,i,o,n,r,u,y,v);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){F=!0,q=g.shift;break}}return _};r(()=>h(ee,l.iconBox,e.cL.horizontal),()=>{const t=l.verticalTextBox;return t&&J(t),n.allowVerticalPlacement&&!(Z&&Z.box&&Z.box.length)&&I>0&&t?h(t,l.verticalIconBox,e.cL.vertical):{box:null,offscreen:null,occluded:null}}),Z&&(F=Z.box,B=Z.offscreen,V=Z.occluded);const d=s(!(!Z||!Z.box));if(!F&&t.prevPlacement){const e=t.prevPlacement.variableOffsets[g];e&&(t.variableOffsets[g]=e,Or(n,e.anchor,i,d));}}else {const a=(s,r)=>{const a=n.getSymbolInstanceTextSize(y,i,t.transform.zoom,o),l=t.collisionIndex.placeCollisionBox(n,a,s,f,m,k,new e.P(0,0),S,p,c,b.predicate);return l&&l.box&&l.box.length&&(Br(n,r,i),t.placedOrientations[g]=r),l};r(()=>a(ee,e.cL.horizontal),()=>{const t=l.verticalTextBox;return n.allowVerticalPlacement&&I>0&&t?(J(t),a(t,e.cL.vertical)):{box:null,offscreen:null,occluded:null}}),s(!!(Z&&Z.box&&Z.box.length));}}if(H=Z,F=H&&H.box&&H.box.length>0,B=H&&H.offscreen,V=H&&H.occluded,i.useRuntimeCollisionCircles){const s=i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex,o=n.text.placedSymbolArray.get(s),l=e.d4(n.textSizeData,y,o),u=a.get("text-padding");W=t.collisionIndex.placeCollisionCircles(n,S,o,s,n.lineVertexArray,n.glyphOffsetArray,l,c,h,d,r,D,b.predicate,i.collisionCircleDiameter*l/e.d1,u,t.retainedQueryData[n.bucketInstanceId].tileID),F=S||W.circles.length>0&&!W.collisionDetected,B=B&&W.offscreen,V=W.occluded;}if(l.iconFeatureIndex&&(Q=l.iconFeatureIndex),l.iconBox){const s=s=>{J(s);const r=i.hasIconTextFit&&q?Fr(q.x,q.y,E,D,t.transform.angle):new e.P(0,0),o=n.getSymbolInstanceIconSize(v,t.transform.zoom,i.placedIconSymbolIndex);return t.collisionIndex.placeCollisionBox(n,o,s,f,m,z,r,C,p,c,b.predicate)};$&&$.box&&$.box.length&&l.verticalIconBox?(X=s(l.verticalIconBox),O=X.box.length>0):(X=s(l.iconBox),O=X.box.length>0),B=B&&X.offscreen,G=X.occluded;}const te=w||0===i.numHorizontalGlyphVertices&&0===I,ie=T||0===i.numIconVertices;if(te||ie?ie?te||(O=O&&F):F=O&&F:O=F=O&&F,F&&H&&H.box&&t.collisionIndex.insertCollisionBox(H.box,a.get("text-ignore-placement"),n.bucketInstanceId,$&&$.box&&Y?Y:K,b.ID),O&&X&&t.collisionIndex.insertCollisionBox(X.box,a.get("icon-ignore-placement"),n.bucketInstanceId,Q,b.ID),W&&(F&&t.collisionIndex.insertCollisionCircles(W.circles,a.get("text-ignore-placement"),n.bucketInstanceId,K,b.ID),r)){const e=n.bucketInstanceId;let i=t.collisionCircleArrays[e];void 0===i&&(i=t.collisionCircleArrays[e]=new Lr);for(let e=0;e<W.circles.length;e+=4)i.circles.push(W.circles[e+0]),i.circles.push(W.circles[e+1]),i.circles.push(W.circles[e+2]),i.circles.push(W.collisionDetected?1:0);}const se="globe"!==n.projection.name;U=U&&(se||!V),N=N&&(se||!G),t.placements[g]=new Pr(F||U,O||N,B||n.justReloaded),s.add(g);},G=t.retainedQueryData[n.bucketInstanceId].tileID;if("offset"===n.elevationType&&t.buildingIndex&&t.buildingIndex.updateZOffset(n,G),"road"===n.elevationType&&n.hdExt&&n.hdExt.updateRoadElevation(n,G.canonical),n.updateZOffset(),n.sortFeaturesByY){const i=n.getSortedSymbolIndexes(t.transform.angle);for(let e=i.length-1;e>=0;--e){const t=i[e];V(n.symbolInstances.get(t),t,n.collisionArrays[t]);}n.hasAnyZOffset&&e.w(`${n.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(n.hasAnyZOffset){const e=n.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];V(n.symbolInstances.get(i),i,n.collisionArrays[i]);}}else for(let e=i.symbolInstanceStart;e<i.symbolInstanceEnd;e++)V(n.symbolInstances.get(e),e,n.collisionArrays[e]);if(r&&n.bucketInstanceId in t.collisionCircleArrays){const i=t.collisionCircleArrays[n.bucketInstanceId];e.aO(i.invProjMatrix,c),i.viewportMatrix=t.collisionIndex.getViewportMatrix();}n.justReloaded=!1;}attemptAnchorPlacement(e,t,i,s,r,o,n,a,l,c,h,d,u,p,f,m,_,g,y,v,b,x){const{textOffset0:w,textOffset1:T,crossTileID:S}=m,C=[w,T],E=Mr(t,n,a,C,l),I=e.collisionIndex.placeCollisionBox(g,l,i,s,r,o,Fr(E.x,E.y,c,h,e.transform.angle),f,d,u,p.predicate);if(v){const t=g.getSymbolInstanceIconSize(x,e.transform.zoom,m.placedIconSymbolIndex);if(0===e.collisionIndex.placeCollisionBox(g,t,v,s,r,o,Fr(E.x,E.y,c,h,e.transform.angle),f,d,u,p.predicate).box.length)return}if(I.box.length>0){let i;return e.prevPlacement&&e.prevPlacement.variableOffsets[S]&&e.prevPlacement.placements[S]&&e.prevPlacement.placements[S].text&&(i=e.prevPlacement.variableOffsets[S].anchor),e.variableOffsets[S]={textOffset:C,width:n,height:a,anchor:t,textScale:l,prevAnchor:i},Or(g,t,m,y),g.allowVerticalPlacement&&(Br(g,y,m),e.placedOrientations[S]=y),{shift:E,placedGlyphBoxes:I}}}}};class Qr{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,s,r,o){const n=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(n,s,e[this._currentTileIndex],this._sortAcrossTiles,o),this._currentTileIndex++,r())return !0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<n.length;)if(t.placeLayerBucketPart(n[this._currentPartIndex],this._seenCrossTileIDs,i,o),this._currentPartIndex++,r())return !0;return !1}}class Jr{constructor(){this._retiredCI=null;}startNewPlacement(e,t,i,s,r,o,n,a,l){return this.placement=new kr(e,s,r,Yr[l||"default"],o,n,a,this._retiredCI),this._retiredCI=null,this._currentPlacementIndex=t.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=i,this._fadeDuration=s,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0;}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0);}isStale(){return !!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,i,s,r,o){const n=e.e.now(),a=()=>!this.isFullPlacementRequested()&&0!==this._fadeDuration&&this.placement.algorithm.shouldPause(e.e.now()-n);for(;this._currentPlacementIndex>=0;){const n=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&"none"!==n.visibility&&(!n.minzoom||n.minzoom<=l)&&(!n.maxzoom||n.maxzoom>l)){const t=n,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),d=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),u=h&&d,p=this._inProgressLayer=this._inProgressLayer||new Qr(t),f=e.m(n.source,n.scope);if(p.continuePlacement(i||u?r[f]:s[f],this.placement,this._showCollisionBoxes,n,a,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._forceFullPlacement=!1,this._done=!0;}commit(e){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(e),this.placement}}const eo=512/e.a2/2;class to{constructor(t,i,s){this.tileID=t,this.bucketInstanceId=s,this.index=new e.d5(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.a2,o=t.canonical.y*e.a2;for(let e=0;e<i.length;e++){const{key:t,crossTileID:s,tileAnchorX:n,tileAnchorY:a}=i.get(e),l=Math.floor((r+n)*eo),c=Math.floor((o+a)*eo);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(s);}this.index.finish();}findMatches(t,i,s){const r=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),o=eo/Math.pow(2,i.canonical.z-this.tileID.canonical.z),n=i.canonical.x*e.a2,a=i.canonical.y*e.a2;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:h}=i,d=Math.floor((n+c)*o),u=Math.floor((a+h)*o),p=this.index.range(d-r,u-r,d+r,u+r).sort((e,t)=>e-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!s.has(t)){s.add(t),i.crossTileID=t;break}}}}}class io{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class so{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],s={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),s[r.tileID.key]=r;}this.indexes[e]=s;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);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 o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,s);}else {const o=r[e.scaledTo(Number(i)).key];o&&o.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.add(r.crossTileID));}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new to(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i);}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const s=this.indexes[i];for(const r in s)e[s[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,s[r]),delete s[r],t=!0);}return t}}class ro{constructor(){this.layerIndexes={},this.crossTileIDs=new io,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={};}addLayer(e,t,i,s){let r=this.layerIndexes[e.fqid];void 0===r&&(r=this.layerIndexes[e.fqid]=new so);let o=!1;const n={};"globe"!==s.name&&r.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),n[t.bucketInstanceId]=!0);}return r.removeStaleBuckets(n)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0;});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}class oo extends e.E{constructor(e){super(),this.requestManager=e,this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}async loadModel(t,i){try{const s=await this.requestManager.transformRequest(i,e.R.Model);return this.modelByURL[i]?(await hi(),ci.loadModel?await ci.loadModel(s.url,t,i):null):null}catch(s){if(404===s.status)return null;this.fire(new e.f(new Error(`Could not load model ${t} from ${i}`,{cause:s})));}}load(t,i,s={forceReload:!1}){this.models[i]||(this.models[i]=Object.create(null));const r=Object.keys(t),o=[],n=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!s.forceReload||(this.modelByURL[r]={modelId:e,scope:i},o.push(this.loadModel(e,r)),n.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1});}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+n.length,Promise.allSettled(o).then(t=>{for(let e=0;e<t.length;e++){const{status:s}=t[e];if("rejected"===s)continue;const{value:r}=t[e];this.models[i][n[e]]||(this.models[i][n[e]]={model:null,numReferences:1}),this.models[i][n[e]].model=r;}this.numModelsLoading[i]-=n.length,this.fire(new e.h("data",{dataType:"style"}));}).catch(t=>{this.fire(new e.f(new Error(`Could not load models: ${t.message}`)));});}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t,i={exactIdMatch:!1}){return !!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]=Object.create(null)),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||Object.create(null)}addModel(e,t,i){this.models[i]||(this.models[i]=Object.create(null)),this.modelUris[i]||(this.modelUris[i]=Object.create(null));const s=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===s)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(s)){const{scope:e,modelId:t}=this.modelByURL[s];this.models[e][t].numReferences++;}else this.modelUris[i][e]=s,this.load({[e]:this.modelUris[i][e]},i);}addModelURLs(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=this.modelUris[t];for(const t of Object.keys(e))i[t]=this.requestManager.normalizeModelURL(e[t]);}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0});}addModelsFromBucket(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=Object.create(null);for(const s of e)this.hasModel(s,t,{exactIdMatch:!0})||this.hasURLBeenRequested(s)?this.models[t][s].numReferences++:this.modelUris[t][s]&&!this.hasURLBeenRequested(s)?i[s]=this.modelUris[t][s]:!this.hasURLBeenRequested(s)&&Re(s,!1)&&(this.modelUris[t][s]=this.requestManager.normalizeModelURL(s),i[s]=this.modelUris[t][s]);this.load(i,t);}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,s=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||s)){const s=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[s];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy();}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy();}this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}listModels(e){return this.models[e]||(this.models[e]=Object.create(null)),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]=Object.create(null));for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const no=["RENDER_SHADOWS","NORMAL_OFFSET"],ao=new Set(["symbol","circle"]),lo=class t{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null;}needsBuild(){return this._needsBuild}buildQueue(e,t,i){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const s=!!i.fog,r=i.hasTerrain(),o=!(!i.projection||"globe"!==i.projection.name),n=r||o,a=!(!i.directionalLight||!i.directionalLight.shadowsEnabled()),l=i.map&&i.map.painter,c=!l||!l.context.extParallelShaderCompile,h=!!l&&"mrt-fallback"===l.emissiveMode,d=(e,t=[],i={})=>{this._queue.push({programId:e,params:{...i.params,defines:t,overrideFog:!!i.fog,overrideTerrain:!!i.terrain,overrideGlobe:!!i.globe,overrideRtt:!!i.rtt,precompiled:!0}});};for(const u of e){if("none"===u.visibility)continue;const e=u.getProgramIds();if(e)for(const p of e){if(ao.has(p))continue;const e=u.getDefaultProgramParams(p,t.zoom,i._styleColorTheme.lut);if(!e)continue;const f=l?l.getShaderSource(p):null,m=n&&(!f||f.usedDefines.has("RENDER_TO_TEXTURE")),_=h&&m?(e.defines||[]).concat("USE_MRT1"):e.defines;if(c){d(p,e.defines,{params:e}),m&&d(p,_,{params:e,rtt:!0});continue}const g=s&&(!f||f.usedDefines.has("FOG")),y=r&&!u.isDraped()&&(!f||f.usedDefines.has("TERRAIN")),v=o&&(!f||f.usedDefines.has("GLOBE")),b=a&&u.hasElevation()&&(!f||f.usedDefines.has("RENDER_SHADOWS"));for(const t of b?[!1,!0]:[!1]){const i=t?(e.defines||[]).concat(no):e.defines||[];for(const t of y?[!1,!0]:[!1])for(const s of v?[!1,!0]:[!1])for(const r of g?[!1,!0]:[!1])d(p,i,{params:e,fog:r,terrain:t,globe:s});}m&&d(p,_,{params:e,rtt:!0});}}if(d("clippingMask"),r)for(const e of [!1,!0])d("terrainRaster",e?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:s});if(!c){if(e.some(e=>"hillshade"===e.type)&&d("hillshadePrepare"),a)for(const e of [!1,!0])for(const t of [!1,!0]){const i=[];e&&i.push("RENDER_CUTOFF"),i.push("RENDER_SHADOWS"),t&&i.push("NORMAL_OFFSET"),d("groundShadow",i),s&&d("groundShadow",i,{fog:!0});}if(o){for(const e of [[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const t of [!1,!0]){const i=[...e,"PROJECTION_GLOBE_VIEW"];t&&i.push("CUSTOM_ANTIALIASING"),d("globeRaster",i,{terrain:r,globe:!0,fog:s});}for(const e of [!1,!0]){const t=e?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];d("globeAtmosphere",t,{fog:!0,terrain:r,globe:e}),d("globeAtmosphere",[...t,"ALPHA_PASS"],{fog:!0,terrain:r,globe:e});}d("stars",[],{fog:s,terrain:r,globe:!0});}}}_executeBatch(i,s,r){if(r.map&&r.map.isMoving())return void(this._idleHandle=e.e.requestIdleCallback(e=>this._executeBatch(e,s,r)));s.context.sweepPendingPrograms();const o=s.context.extParallelShaderCompile?t.DEADLINE_MARGIN_KHR_MS:t.DEADLINE_MARGIN_SYNC_MS;let n=0;for(;this._queue.length>0;){const e=this._queue.shift();if(!e)break;if(s.style=r,s._fogVisible=!!e.params.overrideFog,s.getOrCreateProgram(e.programId,e.params),n++,i.timeRemaining()<=o)break}const a=0===this._queue.length||i.timeRemaining()>o;n>0&&a&&s.context.gl.flush(),this._idleHandle=this._queue.length>0||s.context._pendingPrograms.size>0?e.e.requestIdleCallback(e=>this._executeBatch(e,s,r)):null;}processQueue(t,i){0!==this._queue.length&&(null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=e.e.requestIdleCallback(e=>this._executeBatch(e,t,i)));}reset(){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0;}};lo.DEADLINE_MARGIN_KHR_MS=5,lo.DEADLINE_MARGIN_SYNC_MS=25;let co=lo;const ho=e.s.colorTheme,uo=new e.af({data:new e.ag(ho.data)});function po(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.e.devicePixelRatio,{left:s,top:r,width:o,height:n}=t.metadata.content_area,a=s*i,l=r*i;return [a,l,a+o*i,l+n*i]}function fo(t){if(t)return t.map(([t,i])=>[t*e.e.devicePixelRatio,i*e.e.devicePixelRatio])}class mo{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set;}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name);}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const s=this.sourceCache.getSource();if("raster-array"!==s.type)return t;const r=i.map(e=>this.sourceCache.getTile(e)),o=s.getImages(r,Array.from(this.pendingRequests));for(const[i,s]of o)t.set(e.I.from({name:i,iconsetId:this.id}),s),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const _o=(e,t)=>Tt(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),go=new Set(["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),yo=new Set(["setCenter","setZoom","setBearing","setPitch"]),vo=new Set(["background","sky","slot","custom"]),bo={version:8,layers:[],sources:{}},xo={duration:300,delay:0};class wo extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition={...xo},this._buildingIndex=new wr(this),this.crossTileSymbolIndex=new ro,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers=Object.create(null),this._mergedIndoor={},this._indoorEnabled=!1,this._mergedSourceCaches={},this._mergedOtherSourceCaches=Object.create(null),this._mergedSymbolSourceCaches=Object.create(null),this._mergedFillExtrusionSourceCaches=Object.create(null),this._mergedHdRoadCoverageSourceCaches=Object.create(null),this._mergedHdRoadElevationSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new b,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=i.dispatcher?i.dispatcher:new ei(Sr(),this);const s={referrer:e.d7(),config:e.dp()};if(this.map.painter&&this.map.painter.context){const e=this.map.painter.context.maxUniformBufferBindings,t=Math.floor(this.map.painter.context.maxUniformBlockSize/4);s.contextOptions={maxBindingPoints:e,maxUniformBlockSizeDwords:t};}this.isRootStyle()&&this.dispatcher.broadcast("setGlobalParams",s),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new le(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.d8(t._requestManager,i.localFontFamily?e.d9.all:i.localIdeographFontFamily?e.d9.ideographs:e.d9.none,i.localFontFamily||i.localIdeographFontFamily,i.fontstackCompositing),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new oo(t._requestManager),this.modelManager.setEventedParent(this)),this._layers=Object.create(null),this._sourceCaches={},this._otherSourceCaches=Object.create(null),this._symbolSourceCaches=Object.create(null),this._fillExtrusionSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new co:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._layerExpressionDependencies=i.layerExpressionDependencies?i.layerExpressionDependencies:new Map,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig;const r=this;this._rtlTextPluginCallback=wo.registerForPluginStateChange(t=>{r.dispatcher.send("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL}).then(t=>{if(e.da(null),t.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload();}}).catch(t=>{e.da(t);});}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}});}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.cg(t))return t;const i=e.db(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.dc(JSON.stringify(t))}`}_diffStyle(t,i,s){this.globalId=this._getGlobalId(t),wt();const r=(e,t)=>{try{t(null,this.setState(e,s));}catch(e){t(e,!1);}};if("string"==typeof t){const s=this.map._requestManager.normalizeStyleURL(t),o=new AbortController;this._request={cancel:()=>o.abort()},(async()=>{const t=await this.map._requestManager.transformRequest(s,e.R.Style,o.signal),{data:n}=await e.g(t,o.signal);this._request=null,r(n,i);})().catch(t=>{this._request=null,o.signal.aborted||this.fire(new e.f(t));});}else "object"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.h("dataloading",{dataType:"style"}));const s="boolean"==typeof i.validate?i.validate:!e.cg(t);s&&wt(),this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return void this._load(r,s);const o=new AbortController;this._request={cancel:()=>o.abort()},(async()=>{const i=await this.map._requestManager.transformRequest(t,e.R.Style,o.signal),{data:r}=await e.g(i,o.signal);this._request=null,this.importsCache.set(t,r),this._load(r,s);})().catch(t=>{this._request=null,o.signal.aborted||this.fire(new e.f(t));});}loadJSON(t,i={}){this.fire(new e.h("dataloading",{dataType:"style"}));const s=!1!==i.validate;s&&wt(),this.globalId=this._getGlobalId(t),this._request=e.e.frame(()=>{this._request=null,this._load(t,s);});}loadEmpty(){this.fire(new e.h("dataloading",{dataType:"style"})),this._load(bo,!1);}_loadImports(t,i,s){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const o of t){const t=this._createFragmentStyle(o),n=new Promise(e=>{t.once("style.import.load",e),t.once("error",e);}).then(()=>{this.mergeAll(),this.fire(new e.h("data",{dataType:"style"}));});if(r.push(n),this.resolvedImports.has(o.url)){t.loadEmpty();continue}const a=o.data||this.importsCache.get(o.url);a?(o.data?(t.fire(new e.h("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(a),i&&wt(),queueMicrotask(()=>{t._load(a,i);})):t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):o.url?t.loadURL(o.url,{validate:i}):t.loadEmpty();const l={style:t,id:o.id,config:o.config};if(s){const e=this.fragments.findIndex(({id:e})=>e===s);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e));}else this.fragments.push(l);}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return [...t.values()]}_createFragmentStyle(t){const i=this.scope?e.m(t.id,this.scope):t.id;let s;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(s={...t.config,...r});const o=new wo(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:s,configOptions:this.options,colorThemeOverride:t["color-theme"],layerExpressionDependencies:this._layerExpressionDependencies});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(e=!1){this.mergeAll(),this._updateMapProjection(),e||this.updateConfigDependencies(),this._updateLayers(this._dependentLayerIds(e=>e.isIndoorDependent)),this.map._triggerCameraUpdate(this.camera),(!e||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(e&&this.isRootStyle()?(this.forEachFragmentStyle(e=>{this.dispatcher.broadcast("setLayers",{layers:e._serializeLayers(e._order),scope:e.scope,options:e.options});}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}));}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}async _load(t,i){if(this._isInternalStyle(t)){const e={id:"basemap",data:t,url:""},s={...bo,imports:[e],...t.center?{center:t.center}:{},...t.bearing?{bearing:t.bearing}:{},...t.pitch?{pitch:t.pitch}:{},...t.zoom?{zoom:t.zoom}:{},...t.light?{light:t.light}:{}};return this._importedAsBasemap=!0,void this._load(s,i)}if(this.updateConfig(this._config,t.schema),i){if(await wt(),!this.dispatcher.actors.length)return;if(_o(this,Ct(t)))return}this._loaded=!0;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});this.stylesheet=e.dd(t);const s=()=>{if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const s=Er(this.stylesheet.layers);if(this._order=s.map(e=>e.id),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new Nt(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Nt(this.stylesheet.light)),this._layers=Object.create(null);let r=!1;for(const t of s){const i=e.dj(t,this.scope,this._styleColorTheme.lut,this.options);this._layerExpressionDependencies.set(i.fqid,new x(i)),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._updateHdCoverageSourceCache(i)&&(r=!0);const s=this.getOwnLayerSourceCache(i),o=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&i.canCastShadows()&&o&&(s.castsShadows=!0);}if(r&&Ks().then(()=>{if(!this.map)return;for(const e in this._layers)this._updateHdCoverageSourceCache(this._layers[e]);this.map.style.mergeAll();const e=this.map.transform;for(const t in this.map.style._mergedHdRoadCoverageSourceCaches){const i=this.map.style._mergedHdRoadCoverageSourceCaches[t];i.used=!0,e&&i.update(e);}this.map._update();}),this.glyphManager.url){const e=new Set;for(const t in this._layers){const i=this._layers[t];if("symbol"===i.type&&i.layout){const t=i.layout.get("text-font");t&&t.value&&"constant"===t.value.kind&&e.add(t.value.value.join(","));}}for(const t of e)this.glyphManager.prefetchRange(t,0);}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const o=this.stylesheet.terrain;o&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(o,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.h("data",{dataType:"style"}));const n=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(!0),this.fire(new e.h(n?"style.load":"style.import.load"));}).catch(t=>{this.fire(new e.f(new Error("Failed to load imports",t))),this.fire(new e.h(n?"style.load":"style.import.load"));}):(this._reloadImports(!0),this.fire(new e.h(n?"style.load":"style.import.load")));};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{s();}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),s();});}else this._styleColorTheme.lut=null,s();}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,s,r,o,n,a,l,c;const h={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(d.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),null!=d.light&&(e=d.light),d.stylesheet.lights)for(const e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(t=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(i=d.directionalLight);s=this._prioritizeTerrain(s,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(r=d.fog),d.stylesheet.snow&&null!=d.snow&&(o=d.snow),d.stylesheet.rain&&null!=d.rain&&(n=d.rain),null!=d.stylesheet.camera&&(c=d.stylesheet.camera),null!=d.stylesheet.projection&&(a=d.stylesheet.projection),null!=d.stylesheet.transition&&(l=d.stylesheet.transition),h[d.scope]=d._styleColorTheme;}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=o,this.rain=n,this._styleColorThemeForScope=h,null===s?delete this.terrain:this.terrain=s,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition={...xo,...l},this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const s=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:s?e:null:null!=t&&(!e||s||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);}),null===e?delete this.terrain:this.terrain=e,this._programPrecompiler&&this._programPrecompiler.reset();}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);}),this.projection=e||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset();}mergeSources(){const t={},i=Object.create(null),s=Object.create(null),r=Object.create(null),o=Object.create(null),n=Object.create(null);this.forEachFragmentStyle(a=>{for(const i in a._sourceCaches){const s=e.m(i,a.scope);t[s]=a._sourceCaches[i];}for(const t in a._otherSourceCaches){const s=e.m(t,a.scope);i[s]=a._otherSourceCaches[t];}for(const t in a._symbolSourceCaches){const i=e.m(t,a.scope);s[i]=a._symbolSourceCaches[t];}for(const t in a._fillExtrusionSourceCaches){const i=e.m(t,a.scope);r[i]=a._fillExtrusionSourceCaches[t];}if(a._hdCoverage){const t=a._hdCoverage.coverageSourceCaches;for(const i in t)o[e.m(i,a.scope)]=t[i];}if(a._hdElevation){const e=a._hdElevation.elevationSourceCaches;for(const t in e)n[t]=e[t];}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=s,this._mergedFillExtrusionSourceCaches=r,this._mergedHdRoadCoverageSourceCaches=o,this._mergedHdRoadElevationSourceCaches=n,Object.keys(o).length>0&&!this._hdCoverage&&Xs.HdCoverageState&&(this._hdCoverage=new Xs.HdCoverageState),Xs.updateCrossSourceElevationGate&&Xs.updateCrossSourceElevationGate(this);}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const s=i,r=e.m(s.sourceId,t.scope);this._mergedIndoor[r]=new Set(s.sourceLayers||[]);}}),this._updateIndoorEnabled();}_updateIndoorEnabled(){const t=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("none"!==i.visibility&&this._mergedIndoor[e.m(i.source,i.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||t||this.indoorManager||Ks().then(()=>{this._initIndoorManager();});}_initIndoorManager(){if(!this.indoorManager&&Xs.IndoorManager&&this.isRootStyle()&&0!==Object.keys(this._mergedIndoor).length&&(this.indoorManager=new Xs.IndoorManager(this,this._loaded),this._loaded))for(const e of Object.keys(this._mergedIndoor)){const t=this._mergedSourceCaches[e]||this._mergedOtherSourceCaches[e];t&&t.reload();}}mergeLayers(){const t={},i=[],s=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(s=>{for(const r of s._order){const o=s._layers[r];if("slot"===o.type){const i=e.bV(r);if(t[i])continue;t[i]=[];}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o);}}),this._mergedOrder=[];let r=-1;const o=(i=[])=>{for(const n of i)if("slot"===n.type){const i=e.bV(n.id);t[i]&&o(t[i]),this._mergedSlots.push(i);}else {const t=e.m(n.id,n.scope);this._mergedOrder.push(t),s[t]=n,n.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===n.type&&(this._hasCircleLayers=!0),"symbol"===n.type&&(this._hasSymbolLayers=!0),"clip"===n.type&&(this._clipLayerPresent=!0);}};if(o(i),this._has3DLayers){const e={};for(let t=0;t<this._mergedOrder.length;++t){const i=this._mergedOrder[t];e[i]=t===r?1:t<r?s[i].hasOcclusionOpacityProperties?2:0:4;}this._mergedOrder.sort((t,i)=>e[t]-e[i]);}this._mergedLayers=s,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera={...this.stylesheet.camera,...e},this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,s){const r={...i};for(const e of Object.keys(ho))void 0===r[e]&&(r[e]=ho[e].default);const o=new e.ae(uo,t,new Map(s));return o.setTransitionOrValue(r,s),o.untransitioned().possiblyEvaluate(new e.ai(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((s,r)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void s();let n=t;n.startsWith(o)||(n=o+n);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=n,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void s();this._styleColorTheme.lutLoading=!1;const{width:o,height:n,data:c}=e.e.getImageData(l);if(n>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==n*n)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.b({width:o,height:n},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},s()):r(new Error("Missing LUT image."));};})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.hasTerrain()||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(t){const i=new AbortController;this._spriteRequest=i,function(t,i,s,r){let o,n,a;const l=e.e.devicePixelRatio>1?"@2x":"";function c(t){a||t&&s.aborted||(t&&(a=t),function(){if(a)r(a);else if(o&&n){const t=e.e.getImageData(n),i={};for(const s in o){const{width:r,height:n,x:a,y:l,sdf:c,pixelRatio:h,stretchX:d,stretchY:u,content:p}=o[s],f=new e.b({width:r,height:n});e.b.copy(t,f,{x:a,y:l},{x:0,y:0},{width:r,height:n},null),i[s]={data:f,pixelRatio:void 0!==h?h:1,sdf:void 0!==c&&c,stretchX:d,stretchY:u,content:p,usvg:!1,version:0};}r(null,i);}}());}((async function(){const r=await i.transformRequest(i.normalizeSpriteURL(t,l,".json"),e.R.SpriteJSON,s),{data:n}=await e.g(r,s);a||(o=n);}))().then(()=>c(void 0),e=>c(e)),async function(){const r=await i.transformRequest(i.normalizeSpriteURL(t,l,".png"),e.R.SpriteImage,s),{data:o}=await e.a(r,s);a||(n=o);}().then(()=>c(void 0),e=>c(e));}(t,this.map._requestManager,i.signal,(t,i)=>{if(this._spriteRequest=null,t)this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new e.f(t));else if(i){const t=new Map;for(const s in i)t.set(e.I.from(s),i[s]);this.addImages(t,!0);}this.imageManager.setLoaded(!0,this.scope),this.fire(new e.h("data",{dataType:"style"}));});}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const s=this.getOwnSourceCache(i.source);if(!s)return void this.fire(new e.f(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));if("raster-array"!==s.getSource().type)return void this.fire(new e.f(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));const r=new mo(t,this.scope,s);this.imageManager.addImageProvider(r,this.scope);}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope);}_loadIconset(t){if(!e.cg(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat,s=new AbortController;this._spriteRequest=s,async function(t,i,s,r){try{const o=await i.transformRequest(i.normalizeIconsetURL(t),e.R.Iconset,s),{data:n}=await e.cC(o,s),a={},l=function(e){const t={icons:[]};let i;for(;i=e.nextField(void 0);)1===i&&t.icons.push(C(e,e.readVarint()+e.pos));return t}(new e.cB(n));for(const t of l.icons){const i={version:1,pixelRatio:e.e.devicePixelRatio,content:po(t),stretchX:t.metadata?fo(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?fo(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};a[t.name]=i;}r(null,a);}catch(e){s.aborted||r(e);}}(t,this.map._requestManager,s.signal,(s,r)=>{if(this._spriteRequest=null,s)i?this._loadSprite(t):(this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new e.f(s)));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t,!0);}this.imageManager.setLoaded(!0,this.scope),this.fire(new e.h("data",{dataType:"style"}));});}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const s=t.sourceLayer;s&&("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(s))&&this.fire(new e.f(new Error(`Source layer "${s}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(this.imageManager.hasPatternsInFlight())return !1;if(!this.modelManager.isLoaded())return !1;if(this._styleColorTheme.lutLoading)return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return !!this.snow&&this.snow.hasTransition()}hasRainTransition(){return !!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;if(this.hasSnowTransition())return !0;if(this.hasRainTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1;}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.f(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.f(new Error(`The source '${t}' does not exist in the map's style.`)));}_resolveLayerFragment(t){const i=this.getLayer(t);if(!i)return void this.fire(new e.f(new Error(`The layer '${t}' does not exist in the map's style.`)));const s=this.getFragmentStyle(i.scope);return s?{layer:i,fragment:s}:void 0}handleIdle(){const e=this.map.painter;e&&(e.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(e,this));}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset();}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0;let s=!1;i!==this._brightness&&(this._brightness=i,s=!0),t.worldview!==this._worldview&&(this._worldview=t.worldview,s=!0),s&&this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness,worldview:this._worldview});const r=this._changes.isDirty();let o=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:s}=e[t];(i||s)&&(this._updateWorkerLayers(t,i,s),o=!0);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset();}const n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0;}const a={};for(const i of this._mergedOrder){const s=this._mergedLayers[i];if(("none"!==s.visibility||s.hasTransition())&&s.recalculate(t,this._availableImages),!s.isHidden(t.zoom)){s.mayUse("HD")&&(s.prepare(),Ks()),s.mayUse("Standard")&&(s.prepare(),hi());const e=this.getLayerSourceCache(s);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,s.tileCoverLift()));}if(s.source){const t=e.m(s.source,s.scope),i=this._mergedHdRoadCoverageSourceCaches[t];i&&!i.used&&(i.used=!0);}if("fill-extrusion"===s.type){const t=e.m(s.source,s.scope);if(t in this._mergedFillExtrusionSourceCaches){const e=s.layout&&s.layout.get("source-max-zoom");if(null!=e){const i=a[t];a[t]=null==i?e:Math.min(i,e);}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const e=this._mergedOrder.map(e=>this._mergedLayers[e]);this._programPrecompiler.buildQueue(e,t,this);}for(const e in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[e].setMaxzoomOverride(a[e]??null);this.terrain&&o&&this.mergeLayers();const l=this.imageManager.getPendingImageProviders();for(const e of l)e.sourceCache.used=!0;for(const t in n){const i=this._mergedSourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.h("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),r&&this.fire(new e.h("data",{dataType:"style"}));}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e);}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i]);}for(const t in e)this._changes.resetUpdatedImages(t);}_updateWorkerLayers(e,t,i){const s=this.getFragmentStyle(e);s&&this.dispatcher.broadcast("updateLayers",{layers:t?s._serializeLayers(t):[],scope:e,removedIds:i||[],options:s.options});}setState(t,i){if(this._checkLoaded(),_o(this,Ct(t)))return !1;if((t=e.dd(t)).layers=Er(t.layers),!xt.diffStyles)throw new Error("Debug module not loaded; cannot diff style.");const s=xt.diffStyles(this.serialize(),t).filter(e=>!yo.has(e.command));if(0===s.length)return !1;const r=s.filter(e=>!go.has(e.command));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const o=[];return s.forEach(e=>{o.push(this[e.command](...e.args));}),i&&Promise.all(o).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(e=!1){this._availableImages=this.imageManager.listImages(this.scope);const t={scope:this.scope,images:this._availableImages};e&&(t.isSpriteLoaded=!0),this.dispatcher.broadcast("setImages",t);}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels});}addImages(t,i){if(0===t.size)return i&&this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this;for(const[i,s]of t.entries()){if(this.getImage(i))return this.fire(new e.f(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,s),this._changes.updateImage(i,this.scope);}return this._updateWorkerImages(i),this.fire(new e.h("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.f(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.h("data",{dataType:"style"})),this)}updateImage(t,i,s=!1){this.imageManager.updateImage(t,this.scope,i),s&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.h("data",{dataType:"style"})));}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.h("data",{dataType:"style"})),this):this.fire(new e.f(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.h("data",{dataType:"style"})),this}addModel(t,i,s={}){return this._checkLoaded(),this._validate(kt,`models.${t}`,i,null,s)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.h("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.h("data",{dataType:"style"})),this):this.fire(new e.f(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,s={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(Et,`sources.${t}`,i,null,s))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Object.hasOwn(fr,i.type)&&!cr(i.type),o=r?new mr(t,i,this.dispatcher,this):lr(t,i,this.dispatcher,this);o.scope=this.scope;const n=e=>{e.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(e.id),source:e.serialize(),sourceId:e.id}));};n(o);const a=t=>{const i=(t===e.bR.Symbol?"symbol:":t===e.bR.FillExtrusion?"fill-extrusion:":"other:")+o.id,s=e.m(i,this.scope),r=this._sourceCaches[i]=new gs(s,o,t);t===e.bR.Symbol?this._symbolSourceCaches[o.id]=r:t===e.bR.FillExtrusion?this._fillExtrusionSourceCaches[o.id]=r:this._otherSourceCaches[o.id]=r,r.onAdd(this.map);};a(e.bR.Other),"vector"!==i.type&&"geojson"!==i.type||(a(e.bR.Symbol),"vector"===i.type&&a(e.bR.FillExtrusion)),o.onAdd&&o.onAdd(this.map),r&&async function(e){if(cr(e))return;const t=fr[e];if(!t)throw new Error(`Unknown source type "${e}"`);const i=await t();i&&!cr(e)&&function(e,t){ar[e]=t;}(e,i);}(i.type).then(()=>{const s=cr(i.type),r=this._otherSourceCaches[t];if(!r||r.getSource()!==o)return;if(!s)return void this.fire(new e.f(new Error(`Could not load module for source type "${i.type}".`)));const a=lr(t,i,this.dispatcher,this);a.scope=this.scope,n(a),r.setSource(a),a.onAdd&&a.onAdd(this.map),this._changes.setDirty();}),s.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.f(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.f(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.f(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const s=this.getOwnSourceCaches(t);for(const t of s){const i=e.bV(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.h("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[t],this._hdElevation&&delete this._hdElevation.elevationSourceCaches[e.m(t,this.scope)],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this.dispatcher.broadcast("removeSource",{type:i.type,source:t,scope:i.scope}),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(Dt,"lights",e))return;switch(e.type){case "ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new ti(e,si(),this.scope,this.options);break;case "directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new ti(e,oi(),this.scope,this.options);}}const s=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ai(this.z||0,s);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness});}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const s=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),o=t.properties.get("intensity"),n=t.properties.get("direction"),a=1-e.de(n.x,n.y,n.z)[2]/90,l=s(r)*o*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),h=i.properties.get("intensity"),d=s(c)*h;return Number(((l+d)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.df(t)){const i=e.dg(t),s=this.fragments.find(({id:e})=>e===i);if(!s)return;const r=e.bV(t);return s.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const s in t){const r={},o=this._featuresetSelectors[s]=[];for(const n of t[s].selectors){if(n.featureNamespace){const t=this.getOwnLayer(n.layer);if(!t){e.w(`Layer is undefined for selector: ${n.layer}`);continue}const o=i(t.source,t.sourceLayer);if(o in r&&r[o]!==n.featureNamespace){e.w(`"featureNamespace ${n.featureNamespace} of featureset ${s}'s selector is not associated to the same source, skip this selector`);continue}r[o]=n.featureNamespace;}let t;if(n.properties)for(const i in n.properties){const s=e.c(n.properties[i]);"success"===s.result&&(t=t||{},t[i]=s.value);}o.push({layerId:n.layer,namespace:n.featureNamespace,properties:t,uniqueFeatureID:n._uniqueFeatureID});}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return [];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const s=this.getFragmentStyle(i),r=s.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.f(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const o=[];for(const e of r[t].selectors){const t=s.getOwnLayer(e.layer);t&&o.push(t);}return o}getConfigProperty(t,i){const s=this.getFragmentStyle(t);if(!s)return null;const r=e.m(i,s.scope),o=s.options.get(r),n=o?o.value||o.default:null;return n?n.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(t,i){const s=e.m(t,i);return this._mergedIndoor[s]}setIndoorData(e,t){this.indoorManager&&this.indoorManager.setIndoorData(t);}updateIndoorDependentLayers(){this._updateLayers(this._dependentLayerIds(e=>e.isIndoorDependent)),this.map._styleDirty=!0,this.map.triggerRepaint();}setConfigProperty(t,i,s){const r=this.getFragmentStyle(t);if(!r)return;const o=r.stylesheet.schema;if(!o||!o[i])return;const n=e.dh(s,o[i]);if("success"!==n.result)return void _o(this,n.value);const a=n.value.expression,l=e.m(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:u,stepValue:p,type:f,values:m}=o[i],_=e.dh(o[i].default,o[i]);"success"===_.result&&(h=_.value.expression),h?(this.options.set(l,{...c,value:a,default:h,minValue:d,maxValue:u,stepValue:p,type:f,values:m}),this.updateConfigDependencies(i)):this.fire(new e.f(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)));}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const s=i.stylesheet.schema;if(!s)return null;const r={};for(const t in s){const s=e.m(t,i.scope),o=i.options.get(s),n=o?o.value||o.default:null;r[t]=n?n.serialize():null;}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies());}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies());}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const s in i){let r,o;const n=e.dh(i[s].default,i[s]);if("success"===n.result&&(r=n.value.expression),t&&void 0!==t[s]){const r=e.dh(t[s],i[s]);"success"===r.result&&(o=r.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:d}=i[s];if(r){const t=e.m(s,this.scope);this.options.set(t,{default:r,value:o,minValue:a,maxValue:l,stepValue:c,type:h,values:d});}else this.fire(new e.f(new Error(`No schema defined for config option "${s}".`)));}else this.fire(new e.f(new Error("Attempting to set config for a style without schema.")));}_updateLayers(e){for(const t of e){const e=this.getLayer(t);e&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty());}}_dependentLayerIds(e){const t=[];for(const[i,s]of this._layerExpressionDependencies)e(s)&&t.push(i);return t}updateConfigDependencies(e){this._updateLayers(this._dependentLayerIds(t=>e?t.hasConfigDependency(e):t.isConfigDependent)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t);}}),this._updateIndoorEnabled(),this._changes.setDirty();}addLayer(t,i,s={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.f(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(_o(this,e.di(t)))return;o=e.dj(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.dd(t),t=Object.assign(t,{source:r})),this._validate(Mt,`layers.${r}`,t,{arrayIndex:-1},s))return;o=e.dj(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}});}this._layerExpressionDependencies.set(o.fqid,new x(o));let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.f(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot&&o.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):n=t;}this._order.splice(n,0,r),this._handleLayerOrderChange(),this._layers[r]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.m(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause());}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const s=this._checkLayer(t);if(!s)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.f(new Error(`Layer with id "${i}" does not exist on this map.`)));s.slot&&s.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):o=t;}this._order.splice(o,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._layerExpressionDependencies.delete(t.fqid),this._changes.removeLayer(t);const s=this.getOwnLayerSourceCache(t);if(s&&s.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}s.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const s=this._checkLayer(e);s&&(s.minzoom===t&&s.maxzoom===i||(null!=t&&(s.minzoom=t),null!=i&&(s.maxzoom=i),this._updateLayer(s)));}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(t,i,s={}){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(e.O(r.filter,i))return;const o=this._layerExpressionDependencies.get(r.fqid);if(null==i)return r.filter=void 0,o&&o.invalidateFilter(),void this._updateLayer(r);this._validate(Ft,`layers.${r.id}.filter`,i,{layerType:r.type},s)||(r.filter=e.dd(i),o&&o.invalidateFilter(),this._updateLayer(r));}getFilter(t){const i=this._checkLayer(t);if(i)return e.dd(i.filter)}setLayoutProperty(t,i,s,r={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.O(o.getLayoutProperty(i),s)){if(null!=s&&(!r||!1!==r.validate)&&_o(o,Bt.call(Ct,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:s,styleSpec:e.s,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,s),this._updateLayer(o);}}getLayerProperty(e,t){const i=this._checkLayer(e);if(i){switch(t){case "minzoom":return i.minzoom;case "maxzoom":return i.maxzoom;case "filter":return this.getFilter(e);case "slot":return i.slot;case "appearances":return i.getAppearances().map(e=>e.serialize())}return i.isPaintProperty(t)?this.getPaintProperty(e,t):this.getLayoutProperty(e,t)}}setLayerProperty(e,t,i,s={}){this._checkLoaded();const r=this._checkLayer(e);if(r){switch(t){case "appearances":return r.setAppearances(i),void this._updateLayer(r);case "minzoom":return this.setLayerZoomRange(e,i);case "maxzoom":return this.setLayerZoomRange(e,null,i);case "filter":return this.setFilter(e,i,s);case "slot":return this.setSlot(e,i)}r.isPaintProperty(t)?this.setPaintProperty(e,t,i,s):this.setLayoutProperty(e,t,i,s);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,s,r={}){this._checkLoaded();const o=this._checkLayer(t);o&&(e.O(o.getPaintProperty(i),s)||(null==s||r&&!1===r.validate||!_o(o,Ot.call(Ct,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:s,styleSpec:e.s})))&&(o.setPaintProperty(i,s)&&this._updateLayer(o),this._changes.updatePaintProperties(o)));}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:s}=t.target,r=this.getFragmentStyle(s),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:s}of o)r.setFeatureState({id:t.id,source:e,sourceLayer:s},i);}else if("layerId"in t.target){const e=this._resolveLayerFragment(t.target.layerId);e?.fragment.setFeatureState({id:t.id,source:e.layer.source,sourceLayer:e.layer.sourceLayer},i);}return}const s=t.source,r=t.sourceLayer,o=this._checkSource(s);if(!o)return;const n=o.type;if("geojson"===n&&r)return void this.fire(new e.f(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new e.f(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.f(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(s);for(const e of a)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:s}=t.target,r=this.getFragmentStyle(s),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:s}of o)r.removeFeatureState({id:t.id,source:e,sourceLayer:s},i);}else if("layerId"in t.target){const e=this._resolveLayerFragment(t.target.layerId);e?.fragment.removeFeatureState({id:t.id,source:e.layer.source,sourceLayer:e.layer.sourceLayer},i);}return}const s=t.source,r=this._checkSource(s);if(!r)return;const o=r.type,n="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!n)return void this.fire(new e.f(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.f(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(s);for(const e of a)e.removeFeatureState(n,t.id,i);}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:s,importId:r}=t.target,o=this.getFragmentStyle(r),n=o.getFeaturesetLayers(s);for(const{source:s,sourceLayer:r}of n){const n=o.getFeatureState({id:t.id,source:s,sourceLayer:r});if(n&&!i)i=n;else if(!e.O(i,n))return void this.fire(new e.f(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const e=this._resolveLayerFragment(t.target.layerId);i=e?.fragment.getFeatureState({id:t.id,source:e.layer.source,sourceLayer:e.layer.sourceLayer});}return i}const i=t.source,s=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||s)return void 0===t.id&&this.fire(new e.f(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(s,t.id);this.fire(new e.f(new Error("The sourceLayer parameter must be provided for vector source types.")));}}resetFeatureStates(e){if(this._checkLoaded(),"featuresetId"in e){const{featuresetId:t,importId:i}=e,s=this.getFragmentStyle(i);if(!s)return;const r=s.getFeaturesetLayers(t);for(const{source:e,sourceLayer:t}of r)s.removeFeatureState({source:e,sourceLayer:t});}else {const t=this._resolveLayerFragment(e.layerId);t?.fragment.removeFeatureState({source:t.layer.source,sourceLayer:t.layer.sourceLayer});}}setTransition(e){return this.stylesheet.transition={...this.stylesheet.transition,...e},this.transition=this.stylesheet.transition,this}getTransition(){return {...this.stylesheet.transition}}setWorldview(e){e!==this._worldview&&(this._worldview=e,this.dispatcher.broadcast("upsertRenderParams",{worldview:this._worldview}),this.reloadSources());}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.dk({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t);}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),s=e.m(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[s]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(s,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,s={},r=[];for(let o=i.length-1;o>=0;o--){const n=i[o];if(t(n)){s[n]=o;for(const t of e){const e=t[n];if(e)for(const t of e)r.push(t);}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const o=[];for(let n=i.length-1;n>=0;n--){const a=i[n];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&s[t.layer.id]<n)break;o.push(t),r.pop();}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature);}}return o}queryRasterValue(t,i,s){const r=this.getOwnSource(t);return r?"raster-array"!==r.type?(this.fire(new e.f(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):r.queryRasterArrayValue(i,s):(this.fire(new e.f(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,i,s){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Ft,"queryRenderedFeatures.filter",i.filter,null,i),r=e.bv(i.filter));const o={},n=e=>{if(vo.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=o[t.id]=o[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r});};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.f(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.f(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n(i);}}else for(const e in this._layers)n(this._layers[e]);const a=this._queryRenderedFeatures(t,o,s),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.bW(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,s){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Ft,"queryRenderedFeatures.filter",i.filter,null,i),r=e.bv(i.filter));const o="mock",n=[];if(i&&i.target)n.push({...i,targetId:o,filter:r});else {const e=this.getFeaturesetDescriptors();for(const t of e)n.push({targetId:o,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)n.push({targetId:o,filter:r,target:e});}}const a=this.queryRenderedTargets(t,n,s),l=[],c=new Set;for(const t of a)for(const i of t.variants[o])gr(i,t,c)||l.push(new e.dl(t,i));return l}queryRenderedTargets(t,i,s){const r={},o=(e,t,i,s)=>{const o=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(o.has3DLayers=!0),!s)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push({...i,namespace:s.namespace,properties:s.properties,uniqueFeatureID:s.uniqueFeatureID});};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:s}=t.target,r=this.getFragmentStyle(s);if(!r||!r._featuresetSelectors)continue;const n=r._featuresetSelectors[i];if(!n){this.fire(new e.f(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of n){const i=r.getOwnLayer(e.layerId);i&&!vo.has(i.type)&&o(i,r.getOwnLayerSourceCache(i),t,e);}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||vo.has(i.type))continue;o(i,this.getLayerSourceCache(i),t);}const n=this._queryRenderedFeatures(t,r,s);return this._flattenAndSortRenderedFeatures(n)}_queryRenderedFeatures(t,i,s){const r=[],o=!!this.map._showQueryGeometry,n=Ys.createFromScreenPoints(t,s);for(const e in i){const t=yr(n,i[e],this._availableImages,s,o,this.getActualScope());Object.keys(t).length&&r.push(t);}if(this.placement)for(const t in i){if(i[t].sourceCache._renderSourceType!==e.bR.Symbol)continue;const s=vr(n.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(s).length&&r.push(s);}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Ft,"querySourceFeatures.filter",i,null,t);let s=[];const r=this.getOwnSourceCaches(e);for(const e of r)s=s.concat(br(e,t));return s}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,s={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e.O(t[i],r[i])){o=!0;break}if(!o)return;const n=this._getTransitionParameters();this.light.setLight(t,i,s),this.light.updateTransitions(n);}hasTerrain(){return !!this.terrain&&1===this.terrain.drapeRenderMode}getTerrain(){return this.hasTerrain()?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.e.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."));}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let s=t;const r=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in s&&"object"==typeof s.source){const t="terrain-dem-src";this.addSource(t,s.source),s=e.dd(s),s=Object.assign(s,{source:t});}const t={...s},i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(Pt,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!s)return;this._createTerrain(s,i),this.fire(new e.h("data",{dataType:"style"}));}else {const i=this.terrain,r=i.get();for(const t of Object.keys(e.s.terrain))!Object.hasOwn(s,t)&&e.s.terrain[t].default&&(s[t]=e.s.terrain[t].default);for(const s in t)if(!e.O(t[s],r[s])){i.set(t,this.options),this.stylesheet.terrain=t;const s=this._getTransitionParameters({duration:0});i.updateTransitions(s),this.fire(new e.h("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new Zt(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createSnow(e){const t=this.snow=new Wt(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createRain(e){const t=this.rain=new Xt(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity();});}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){const i=this.fog;if(!e.O(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset();}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.O(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createSnow(t);this._markersNeedUpdate=!0;}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.O(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createRain(t);this._markersNeedUpdate=!0;}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const s=this._evaluateColorThemeData(i);this._loadColorTheme(s).then(()=>{this.fire(new e.h("colorthemeset")),t();}).catch(t=>{e.w(`Couldn't set color theme: ${t}`);});}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme();}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme());}_getTransitionParameters(t){return {now:e.e.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new Vt(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const s=this._getTransitionParameters({duration:0});i.updateTransitions(s);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(t,i,s,r,o={}){if(o&&!1===o.validate)return !1;const n={...this.serialize()};return _o(this,t.call(Ct,{key:i,style:n,value:s,styleSpec:e.s,...r}))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),e.dm.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];t.clearTiles(),t.setEventedParent(null);const i=t.getSource();i&&i.onRemove&&i.onRemove(this.map);}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager&&this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear();}}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope);});}updateSources(t){let i;this.directionalLight&&(i=e.dn(this.directionalLight));const s=new Set,r=new Set,o=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?s.add(t.source):"raster"!==t.type||!t.paint||"ground"!==t.paint.get("raster-elevation-reference")&&!1!==t.paint.get("raster-allow-draping")||o.add(t.source),t.hasElevation()&&!r.has(t.source)&&r.add(t.source);}this.updateFrcCoverageFadeRange();for(const e in this._mergedSourceCaches){const n=this._mergedSourceCaches[e],a=r.has(n._source.id);n._isRasterElevatedOverTerrain=o.has(n._source.id),s.has(n._source.id)&&(n._source.reparseOverscaled=!1),n.update(t,void 0,void 0,i,a);}this.updateFrcCoverage(),this.updateElevationCoverage(),Xs.markElevationIngestSourceCachesUsed&&Xs.markElevationIngestSourceCachesUsed(this);}_reloadSources(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}updateFrcCoverageFadeRange(){this.map.painter&&Xs.updateFrcCoverageFadeRange&&Xs.updateFrcCoverageFadeRange(this,this.map.painter);}updateFrcCoverage(){this._hdCoverage&&Xs.updateFrcCoverage&&Xs.updateFrcCoverage(this,this._hdCoverage);}updateElevationCoverage(){this.isRootStyle()&&Xs.setupAndUpdateElevationCoverage&&Xs.setupAndUpdateElevationCoverage(this);}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.h("neworder"));}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Jr),this.pauseablePlacement.requestFullPlacement();}_setLabelPlacementStale(){this.placement&&this.placement.setStale();}_updatePlacement(t,i,s,r,o,n){this.pauseablePlacement||(this.pauseablePlacement=new Jr);let a=!1,l=!1;const c={},h={};for(const i of this._mergedOrder){const s=this._mergedLayers[i];if("symbol"!==s.type)continue;const r=e.m(s.source,s.scope);let o=c[r];if(!o){const e=this.getLayerSourceCache(s);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),o=c[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1));}const n=this.crossTileSymbolIndex.addLayer(s,o,t.center.lng,t.projection);a=a||n;}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const d=Boolean(this.placement&&!t.equals(this.placement.transform)),u=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!o||this.placement.lastReplacementSourceUpdateTime!==o.updateTime)),p=d||u||a,f=(p||this.pauseablePlacement.isStale())&&0===s,m=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.e.now(),t.zoom)&&0!==s;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||f||m)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,s,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex,n),this.map.painter)){const e=this.map.painter.maxFrontCutoffRawStart;if(e>0){const i=180*t.pitch/Math.PI;if(i>=15){const t=Math.min(1,Math.max(0,(i-15)/5)),s=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-s)+e*s;}}}if(this.pauseablePlacement.isDone()?p&&0!==s&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,c,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.e.now()),l=!0),a&&this.pauseablePlacement.setStale()),l||a){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;t<this._mergedOrder.length;t++){const s=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==s.type)continue;if("none"===s.visibility)continue;const r=this.isLayerClipped(s);this.placement.updateLayerOpacities(s,c[e.m(s.source,s.scope)],t,r?o:null,i,this.map.painter.scaleFactor);}}return !this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(e.e.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(t,i){if(this._checkLoaded(),new Set(["__proto__","constructor","prototype"]).has(t.id))return void this.fire(new e.f(new Error(`Import id can't be "${t.id}".`)));const s=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==s.findIndex(({id:e})=>e===t.id))return void this.fire(new e.f(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return s.push(t),this._loadImports([t],!0);const r=s.findIndex(({id:e})=>e===i);return -1===r&&this.fire(new e.f(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=s.slice(0,r).concat(t).concat(s.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const s=this.stylesheet.imports||[],r=this.getImportIndex(t);return -1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==s[r].url&&this.setImportUrl(t,i.url),e.O(i.config,s[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.O(i.data,s[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const s=this.getImportIndex(e);if(-1===s)return this;const r=this.getImportIndex(t);if(-1===r)return this;const o=i[s],n=this.fragments[s];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(o).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(n).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],s=this.getImportIndex(e);if(-1===s)return this;i[s].url=t;const r=this.fragments[s];return r.style=this._createFragmentStyle(i[s]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),s=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete s[i].data,this.setImportUrl(e,s[i].url))}setImportConfig(e,t,i){this._checkLoaded();const s=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===s)return this;t?r[s].config=t:delete r[s].config;const o=this.fragments[s];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const n=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.style.updateConfig(t,n),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports());}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return -1===i&&this.fire(new e.f(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const s=e.m(t,i);return this._mergedOtherSourceCaches[s]}getLayerSourceCache(t){const i=e.m(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type?this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]:"fill"===t.type&&t.sourceLayer===e.bU&&this._mergedHdRoadCoverageSourceCaches[i]?this._mergedHdRoadCoverageSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){return null==e?Object.values(this._mergedSourceCaches):[this._mergedOtherSourceCaches[e],this._mergedSymbolSourceCaches[e],this._mergedFillExtrusionSourceCaches[e],this._mergedHdRoadCoverageSourceCaches[e],this._mergedHdRoadElevationSourceCaches[e]].filter(Boolean)}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e);}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:"fill-extrusion"===e.type&&this._fillExtrusionSourceCaches[e.source]||this._otherSourceCaches[e.source]}getOwnSourceCaches(t){return [this._otherSourceCaches[t],this._symbolSourceCaches[t],this._fillExtrusionSourceCaches[t],this._hdCoverage&&this._hdCoverage.coverageSourceCaches[t],this._hdElevation&&this._hdElevation.elevationSourceCaches[e.m(t,this.scope)]].filter(Boolean)}_updateHdCoverageSourceCache(t){return Xs.HdCoverageState&&Xs.updateHdCoverageSourceCache?(this._hdCoverage||(this._hdCoverage=new Xs.HdCoverageState),Xs.updateHdCoverageSourceCache(this,this._hdCoverage,t),!1):"fill"===t.type&&t.sourceLayer===e.bU}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.f(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return !1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),s="building"===e.type;if(e.is3D(!!this.terrain)){if(i||s||t&&"batched-model"===t.type)return !0;if("model"===e.type)return !0}else if("symbol"===e.type)return !0;return !1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove();}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}async getImages(t,i){const s=new Promise((e,t)=>{this.imageManager.getImages(i.icons.concat(i.patterns),i.scope,(i,s)=>{i?t(i):e(s);});});this._updateTilesForChangedImages();const r=i.icons.map(t=>e.I.toString(t)),o=i.patterns.map(t=>e.I.toString(t)),n=e=>{e&&(e.setDependencies(i.tileID.key,"icons",r),e.setDependencies(i.tileID.key,"patterns",o));},a=e.m(i.source,i.scope);return n(this._mergedOtherSourceCaches[a]),n(this._mergedSymbolSourceCaches[a]),(i.icons.some(e=>e.iconsetId)||i.patterns.some(e=>e.iconsetId))&&this.fire(new e.h("data",{dataType:"style"})),s}async rasterizeImages(e,t){return new Promise((e,i)=>{this.imageManager.rasterizeImages(t,(t,s)=>{t?i(t):e(s);});})}async checkAtlasCache(e,t){const i=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);return i&&i.contentDescriptor?{iconPositions:i.iconPositions,patternPositions:i.patternPositions,sourceHash:i.contentDescriptor.hash}:null}async getGlyphs(e,t){return new Promise((e,i)=>{this.glyphManager.getGlyphs(t.stacks,(t,s)=>{t?i(t):e(s);});})}}wo.registerForPluginStateChange=e.d6;class To{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,s,r,o,n,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==s.length;for(let e=0;!l&&e<s.length;e++)this.boundPaintVertexBuffers[e]!==s[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==n.length;for(let e=0;!c&&e<n.length;e++)this.boundDynamicVertexBuffers[e]!==n[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==o)this.freshBind(t,i,s,r,o,n,a);else {e.bindVertexArrayOES.set(this.vao);for(const i of n)i&&(i.bind(),a&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,a));r&&r.dynamicDraw&&r.bind();}}freshBind(e,t,i,s,r,o,n){const a=this.context,l=a.gl;this.vao&&this.destroy(),this.vao=a.gl.createVertexArray(),a.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=s,this.boundVertexOffset=r,this.boundDynamicVertexBuffers=o,t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of i)t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of o)t&&(t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r),n&&t.instanceCount&&t.setVertexAttribDivisor(l,e,n));s&&s.bind();}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null);}}function So(t,i){const s=Math.pow(2,i.canonical.z),r=i.canonical.y;return [new e.bS(0,r/s).toLngLat().lat,new e.bS(0,(r+1)/s).toLngLat().lat]}function Co(t,i,s,r,o,n,a){const l=t.context,c=l.gl,h=s.hillshadeFBO;if(!h)return;t.prepareDrawTile();const d=t.isTileAffectedByFog(i),u=[];t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&u.push("USE_MRT1");const p=t.getOrCreateProgram("hillshade",{overrideFog:d,defines:u});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment0.get());const f=((t,i,s,r)=>{const o=s.paint.get("hillshade-shadow-color"),n="none"===s.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=s.paint.get("hillshade-highlight-color"),l="none"===s.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=s.paint.get("hillshade-accent-color"),h="none"===s.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=s.paint.get("hillshade-emissive-strength");let u=e.au(s.paint.get("hillshade-illumination-direction"));if("viewport"===s.paint.get("hillshade-illumination-anchor"))u-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),s=e.de(i.x,i.y,i.z);u=e.au(s[1]);}const p=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:So(0,i.tileID),u_light:[s.paint.get("hillshade-exaggeration"),u],u_shadow:o.toPremultipliedRenderColor(n?null:s.lut),u_highlight:a.toPremultipliedRenderColor(l?null:s.lut),u_emissive_strength:d,u_accent:c.toPremultipliedRenderColor(h?null:s.lut)}})(t,s,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,p,i.toUnwrapped());const{tileBoundsBuffer:m,tileBoundsIndexBuffer:_,tileBoundsSegments:g}=t.getTileBoundsBuffers(s);p.draw(t,c.TRIANGLES,o,n,a,e.$.disabled,f,r.id,m,_,g);}function Eo(t,i,s){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(s.stride);const n=s.getPixels();i.demTexture?i.demTexture.update(n,{premultiply:!1}):i.demTexture=new e.T(r,n,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function Io(t,i,s){const r=t.context,o=r.gl;if(!i.dem)return;const n=i.dem;if(r.activeTexture.set(o.TEXTURE1),Eo(t,i,n),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=n.dim;r.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},o.RGBA8);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers(),u=[];t.linearFloatFilteringSupported()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&u.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(t,o.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.unblended,e.$.disabled,((t,i)=>{const s=i.stride,r=e.Y();return e.dr(r,0,e.a2,-e.a2,0,0,1),e.bM(r,r,[0,-e.a2,0]),{u_matrix:r,u_image:1,u_dimension:[s,s],u_zoom:t.overscaledZ}})(i.tileID,n),s.id,c,h,d),i.needsHillshadePrepare=!1;}class Do{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 Po extends Do{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}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 Lo extends Do{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class Ro extends Do{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class Ao extends Do{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 Mo extends Do{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Fo extends Do{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Oo extends Do{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 Bo extends Do{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 ko extends Do{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 zo extends Do{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 Uo extends Do{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 No extends Do{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class jo extends Do{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 Vo extends Do{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}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.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Go extends Do{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}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 qo extends Do{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class Zo extends Do{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 $o extends Do{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Ho extends Do{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let Wo=class extends Do{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class Xo extends Do{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class Ko extends Do{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 Yo extends Do{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 Qo extends Do{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 Jo extends Do{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 en extends Do{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 tn extends Do{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class sn extends Do{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class rn extends Do{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 on extends Do{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 nn extends Do{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 an extends Do{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class ln extends an{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i;}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,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class cn extends an{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class hn extends an{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class dn extends cn{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const un=(e,t,i,s)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:s}),pn=(e,t,i,s,r,o,n,a,l,c,h,d,u,p,f,m,_)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(s),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:o,u_image0:0,u_image1:1,u_frustum_tl:n,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:d,u_viewport:u,u_grid_matrix:_?Float32Array.from(_):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f,u_emissive_texture_available:m});function fn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const mn=new class{constructor(){this.operations={};}newMorphing(e,t,i,s,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:s,phase:0,duration:r,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}};function _n(e,t,i){if(0===t)return 0;const s=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*s}function gn(e,t){const i=1<<e.z;return !t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}function yn(e,t){if(!e.style||!e.style.enable3dLights())return;const i=e.context,s=i.gl;i.activeTexture.set(s.TEXTURE1),t?t.bind(s.LINEAR,s.CLAMP_TO_EDGE):e.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);}class vn extends gs{constructor(e){const t={type:"raster-dem",maxzoom:Math.ceil(e.transform.maxZoom)},i=lr("mock-dem",t,e.style.dispatcher,e.style);super("mock-dem",i,null),i.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class bn extends gs{constructor(e){const t=lr("proxy",{type:"geojson",maxzoom:Math.ceil(e.transform.maxZoom)},e.style.dispatcher,e.style);super("proxy",t,null),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const s=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new fs(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t;}return t},{});for(const e in this._tiles)e in s||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class xn extends e.bP{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class wn extends e.cW{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[s,r,o]=function(){const t=new e.bC,i=new e.ad,s=131;t.reserve(17161),i.reserve(33800);const r=e.a2/128,o=e.a2+r/2,n=o+r;for(let i=-r;i<n;i+=r)for(let s=-r;s<n;s+=r){const r=s<0||s>o||i<0||i>o?24575:0,n=e.b0(Math.round(s),0,e.a2),a=e.b0(Math.round(i),0,e.a2);t.emplaceBack(n+r,a);}const a=(e,t)=>{const r=t*s+e;i.emplaceBack(r+1,r,r+s),i.emplaceBack(r+s,r+s+1,r+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);}),[t,i,32768]}(),n=t.context;this.gridBuffer=n.createVertexBuffer(s,e.bE.members),this.gridIndexBuffer=n.createIndexBuffer(r),this.gridSegments=e.ac.simpleSegment(0,0,s.length,r.length),this.gridNoSkirtSegments=e.ac.simpleSegment(0,0,s.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new bn(i.map),this.orthoMatrix=e.Y(),e.dr(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.a2,0,e.a2,0,1);const a=n.gl;this._overlapStencilMode=new e._({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new vn(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null;}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache();});}update(t,i,s){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,o=0===t.terrain.drapeRenderMode,n=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.e.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=n?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&n&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,s),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,s=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=s;const r=null!=i?s-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const o=t.zoom,n=this._style.terrain;if(!this._previousUpdateTimestamp)return n.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const h=n.getExaggeration(c),d=h===n.getExaggeration(Math.max(0,c-.1));if(d&&Math.abs(h-this._exaggeration)<.01)return h;let u=Math.min(.1,.00375*(this._updateTimestamp-l));return (d||h<.1||Math.abs(a)<1e-4)&&(u=Math.min(.2,4*u)),e.al(this._exaggeration,h,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,s=this.painter.transform;this._initializing&&(this._initializing=0===s._centerAltitude&&-1===this.getAtPointOrZero(e.bS.fromLngLat(s.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=s.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const s=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(s.x,s.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const s=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),n=r.mult(1<<t.canonical.z);return n.x-=.5,n.y-=.5,n.distSqr(s)-n.distSqr(o)});}(r,this.painter);const o=this.proxyToSource||{};this.proxyToSource={},r.forEach(e=>{this.proxyToSource[e.key]={};}),this.terrainTileForTile={};const n=this._style._mergedSourceCaches;for(const e in n){const i=n[e];if(!i.used)continue;if(!i.transform)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const s=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(s);}this.proxiedCoords[i.id]=r.map(e=>new xn(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);});}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const s=this.terrainTileForTile[i],r=s.dem;!r||s.demTexture&&!s.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Eo(this.painter,s,r));}}_prepareDemTileUniforms(e,t,i,s){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),n=s||"";return i[`u_dem_tl${n}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${n}`]=o,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const s=i.dem.tree.minimums[0];return s>0&&e++,t+s},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const s=this._getLoadedAreaMinimum(),r=new e.dv({width:1,height:1},new Float32Array([s]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),o}setupElevationDraw(t,i,s){const r=this.painter.context,o=r.gl,n={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};n.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(s&&s.morphing&&this._useVertexMorphing){const e=s.morphing.srcDemTile,i=s.morphing.dstDemTile;c=s.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,n,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,n)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let d=null;var u;if(this.enabled?l&&a?(d=a.demTexture,r.activeTexture.set(o.TEXTURE4),l.demTexture.bind(h(l),o.CLAMP_TO_EDGE),n.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,a,n)?a.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,r.activeTexture.set(o.TEXTURE2),d&&(n.u_dem_size=1===(u=d).size[0]?1:u.size[0]-2,d.bind(h(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(s&&s.useDepthForOcclusion,i,n),s&&s.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.dw(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;n.u_meter_to_dem=t;}if(s&&s.labelPlaneMatrixInv&&(n.u_label_plane_matrix_inv=s.labelPlaneMatrixInv),i.setTerrainUniformValues(r,n),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,s&&s.useDenormalizedUpVectorScale);i.setGlobeUniformValues(r,e);}}globeUniformValues(t,i,s){const r=t.projection;return {u_tile_tl_up:r.upVector(i,0,0),u_tile_tr_up:r.upVector(i,e.a2,0),u_tile_br_up:r.upVector(i,e.a2,e.a2),u_tile_bl_up:r.upVector(i,0,e.a2),u_tile_up_scale:s?e.dx(1):r.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const i=this.painter,s=this.painter.context;0!==t.length&&(s.bindFramebuffer.set(null),s.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,s,r,o){if("globe"===t.transform.projection.name)!function(t,i,s,r,o){const n=t.context,a=n.gl;let l,c;const h=t.transform,d=e.dt(t,n,h),u=(e,i)=>{if(c===i)return;const s=[];1===i&&s.push("TERRAIN_VERTEX_MORPHING"),s.push("PROJECTION_GLOBE_VIEW"),d&&s.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:s,overrideFog:r}),c=i;},p=t.colorModeForRenderPass(),f=new e.Z(a.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D);mn.update(o);const m=e.b6(h),_=[e.a7(h.center.lng),e.a8(h.center.lat)],g=t.globeSharedBuffers,y=[h.width*e.e.devicePixelRatio,h.height*e.e.devicePixelRatio],v=Float32Array.from(h.globeMatrix),b={useDenormalizedUpVectorScale:!0};{const h=t.transform,d=_n(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const x=a.TRIANGLES;for(const c of r){const r=s.getTile(c),w=e._.disabled,T=i.prevTerrainTileForTile[c.key],S=i.terrainTileForTile[c.key];fn(T,S)&&mn.newMorphing(c.key,T,S,o,250),yn(t,r.emissiveTexture),n.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const C=mn.getMorphValuesForProxy(c.key),E=C?1:0;C&&Object.assign(b,{morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:e.ds(C.phase)}});const I=e.b2(c.canonical),D=e.b3(I.getCenter().lat),P=e.b7(c.canonical,I,D,h.worldSize/h._pixelsPerMercatorPixel),L=e.b4(e.b5(c.canonical)),R="mrt-fallback"===t.emissiveMode?1:0,A=pn(h.expandedFarZProjMatrix,v,m,L,e.S(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,d,h._farZ,R,P);if(u(c,E),l&&(i.setupElevationDraw(r,l,b),t.uploadCommonUniforms(n,l,c.toUnwrapped()),g)){const[i,s,r]=g.getGridBuffers(D,0!==d);l.draw(t,x,f,w,p,e.$.backCCW,A,"globe_raster",i,s,r);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of r){const{x:r,y:c,z:d}=o.canonical,u=0===c,m=c===(1<<d)-1,[v,x,w,T]=g.getPoleBuffers(d,!1);if(T&&(u||m)){const c=s.getTile(o);yn(t,c.emissiveTexture),n.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let g=e.du(d,r,h);const S=e.b4(e.b5(o.canonical)),C="mrt-fallback"===t.emissiveMode?1:0,E=(i,s)=>i.draw(t,a.TRIANGLES,f,e._.disabled,p,e.$.disabled,pn(h.expandedFarZProjMatrix,g,g,S,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,0,h._farZ,C),"globe_pole_raster",s,w,T);i.setupElevationDraw(c,l,b),t.uploadCommonUniforms(n,l,o.toUnwrapped()),u&&t.renderDefaultNorthPole&&E(l,v),m&&t.renderDefaultSouthPole&&(g=e.aN(e.Y(),g,[1,-1,1]),E(l,x));}}}}(t,i,s,r,o);else {const n=t.context,a=n.gl;let l,c;const h=t.shadowRenderer,d=e.aE(t,t.longestCutoffRange),u=e=>{if(c===e)return;const i=[];1===e&&i.push("TERRAIN_VERTEX_MORPHING"),d.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},p=t.colorModeForRenderPass(),f=new e.Z(a.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D);mn.update(o);const m=t.transform,_=_n(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const i=t.style.directionalLight,s=t.style.ambientLight;i&&s&&(g=e.aF(t.style,i,s));}{c=-1;const y=a.TRIANGLES,[v,b]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=s.getTile(c),x=e._.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];fn(w,T)&&mn.newMorphing(c.key,w,T,o,250),yn(t,r.emissiveTexture),n.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=mn.getMorphValuesForProxy(c.key),C=S?1:0;let E;S&&(E={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.ds(S.phase)}});const I="mrt-fallback"===t.emissiveMode?1:0,D=un(c.projMatrix,gn(c.canonical,m.renderWorldCopies)?_/10:_,g,I);if(u(C),!l)continue;i.setupElevationDraw(r,l,E);const P=c.toUnwrapped();h&&h.setupShadows(P,l),t.uploadCommonUniforms(n,l,P,null,d),l.draw(t,y,f,x,p,e.$.backCCW,D,"terrain_raster",i.gridBuffer,v,b);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,s=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],n=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const h of o){const o=r.getTileByID(h.proxyTileKey),d=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,u=void 0!==d?r.renderCache[d]:this.pool[c++],p=void 0!==d;if(o.texture=u.tex,o.emissiveTexture=u.emissiveTex,p&&!u.dirty){l.push(o.tileID);continue}s.bindFramebuffer.set(u.fb.framebuffer);const f=s.gl;let m;f.drawBuffers("mrt-fallback"===i.emissiveMode?[f.COLOR_ATTACHMENT0,f.COLOR_ATTACHMENT1]:[f.COLOR_ATTACHMENT0]),this.renderedToTile=!1,u.dirty&&(s.clear({color:e.C.transparent,stencil:0}),u.dirty=!1);for(let e=n.start;e<=n.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[h.key][r.id]:[h];if(!o)continue;const n=o;s.viewport.set([0,0,u.fb.width,u.fb.height]),m!==(r?r.id:null)&&(this._setupStencil(u,o,t,r),m=r?r.id:null),i.renderLayer(i,r,t,n);}if(f.drawBuffers([f.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[h.key][r.id]:[h];if(!o)continue;const n=o;s.viewport.set([0,0,u.fb.width,u.fb.height]),m!==(r?r.id:null)&&(this._setupStencil(u,o,t,r),m=r?r.id:null),i.renderLayer(i,r,t,n);}this.renderedToTile?(u.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,s.bindFramebuffer.set(null),s.viewport.set([0,0,i.width,i.height]),n.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,s=t;for(let r=0;r<t;++r)this._style.isLayerDraped(e._mergedLayers[e.order[r]])?i=Math.max(i,r):s=Math.min(s,r);return s>i}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0]);}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const s=this._visibleDemTiles.filter(e=>e.dem).map(s=>{const r=s.tileID,o=1<<r.overscaledZ,{x:n,y:a}=r.canonical,l=n/o,c=(n+1)/o,h=a/o,d=(a+1)/o;return {minx:l,miny:h,maxx:c,maxy:d,t:s.dem.tree.raycastRoot(l,h,c,d,e,t,i),tile:s}});s.sort((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of s){if(null==r.t)return null;const s=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=s)return s}return null}_createFBO(){const t=this.painter.context,i=t.gl,s=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:s[0],height:s[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(s[0],s[1],1,null);let n;return o.colorAttachment0.set(r.texture),this._emissiveTexture&&(n=new e.T(t,{width:s[0],height:s[1],data:null},i.R8),n.bind(i.LINEAR,i.CLAMP_TO_EDGE),o.createColorAttachment(t,1),o.colorAttachment1.set(n.texture)),o.depthAttachment=new dn(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,s[0],s[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:r,emissiveTex:n,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e;}}_updateFBO(t,i){const s=t.fb,r=this.painter.context,o=r.gl,n=this.drapeBufferSize;if(i){const i=new e.T(r,{width:n[0],height:n[1],data:null},o.R8);i.bind(o.LINEAR,o.CLAMP_TO_EDGE),t.emissiveTex=i,s.createColorAttachment(r,1),s.colorAttachment1.set(i.texture);}else t.emissiveTex=void 0,s.removeColorAttachment(r,1);t.dirty=!0;}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO());}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return !0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return !0;return this._style.order.some(e=>{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof tr){t=!0;break}if(!t)return;const i={};for(let t=0;t<this._style.order.length;++t){const s=this._style._mergedLayers[this._style.order[t]],r=this._style.getLayerSourceCache(s);if(!r||i[r.id])continue;if(s.isHidden(this.painter.transform.zoom)||"line"!==s.type)continue;const o=s.widthExpression(),n=s.emissiveStrengthExpression();if(o instanceof e.aj||n instanceof e.aj){i[r.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t)this._clearRenderCacheForTile(r.id,e);}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof ir){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],s=this._style.getLayerSourceCache(i);if(!s||t[s.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const r=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][s.id];if(t)for(const e of t){const t=Ai(s.getTile(e),s.findLoadedParent(e,0),s,this.painter.transform,r);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(s.id,e);}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const t=this._style.order,i=t.length;if(0===i)return;const s=[];this._pendingGroundEffectLayers=[];let r,o=0,n=this._style._mergedLayers[t[o]];for(;!this._style.isLayerDraped(n)&&n.isHidden(this.painter.transform.zoom)&&++o<i;)n=this._style._mergedLayers[t[o]];for(;o<i;++o){const e=this._style._mergedLayers[t[o]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===r&&(r=o):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(o),void 0!==r&&(s.push({start:r,end:o-1}),r=void 0)));}if(void 0!==r&&s.push({start:r,end:o-1}),0!==s.length){const t=s.at(-1);this._pendingGroundEffectLayers.every(e=>e>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=s;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const s=Object.values(e[i]);t.renderCachePool.push(...s);}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,s=this._tilesDirty;for(let r=i.length-1;r>=0;r--){const o=i[r];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],r=this.proxyToSource[o.key];let n=0;for(const e in r){const t=r[e],o=i[e];if(!o||o.length!==t.length||t.some((t,i)=>t!==o[i]||s[e]&&Object.hasOwn(s[e],t.key))){n=-1;break}++n;}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=n<0||n!==Object.values(i).length;}}const r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const s of i){if(t.proxyCachedFBO[s.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[s.key]={},t.proxyCachedFBO[s.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,s){if(!s||!this._sourceTilesOverlap[s.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let n;if(i.isTileClipped())n=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t.at(-1).overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+n>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return "Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e._.disabled}_renderTileClippingMasks(t,i){const s=this.painter,r=this.painter.context,o=r.gl;s._tileClippingMaskIDs={},r.setColorMode(e.a1.disabled),r.setDepthMode(e.Z.disabled);const n=s.getOrCreateProgram("clippingMask");for(const r of t){const t=s._tileClippingMaskIDs[r.key]=--i;n.draw(s,o.TRIANGLES,e.Z.disabled,new e._({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.a1.disabled,e.$.disabled,Us(r.projMatrix),"$clipping",s.tileExtentBuffer,s.quadTriangleIndexBuffer,s.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const s=[t.x,t.y,1,1];e.c7(s,s,i.pixelMatrixInverse),e.dy(s,s,1/s[3]),s[0]/=i.worldSize,s[1]/=i.worldSize;const r=i._camera.position,o=e.dw(1,i.center.lat),n=[r[0],r[1],r[2]/o,0],a=e.dz([],s.slice(0,3),n);e.c3(a,a);const l=this.raycast(n,a,this._exaggeration);return null!==l&&l?(e.dA(n,n,a,l),n[3]=n[2],n[2]*=o,n):null}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof nr)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const s=this.proxiedCoords[e.id]=[],r=this.proxyCoords;for(let t=0;t<r.length;t++){const o=r[t],n=this._findTileCoveringTileID(o,e);if(n){const t=this._createProxiedId(o,n,i[o.key]&&i[o.key][e.id]);s.push(t),this.proxyToSource[o.key][e.id]=[t];}}let o=!1;const n=new Set;for(let r=0;r<t.length;r++){const a=e.getTile(t[r]);if(!a||!a.hasData())continue;const l=this._findTileCoveringTileID(a.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==a.tileID.canonical.z){const t=this.proxyToSource[l.tileID.key][e.id],r=this._createProxiedId(l.tileID,a,i[l.tileID.key]&&i[l.tileID.key][e.id]);t?t.splice(t.length-1,0,r):this.proxyToSource[l.tileID.key][e.id]=[r];const c=this.proxyToSource[l.tileID.key][e.id];n.has(c)||n.add(c),s.push(r),o=!0;}}if(this._sourceTilesOverlap[e.id]=o,o)for(const e of n)e.sort((e,t)=>t.overscaledZ-e.overscaledZ);}_setupProxiedCoordsForImageSource(t,i,s){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords,n=t.getSource(),a=n.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=n.coordinates.map(e.bS.fromLngLat).reduce((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const s=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),o=e.a2/(1<<t.canonical.z),n=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return s+o<n+c.min.x||s>n+c.max.x||r+o<a+c.min.y||r>a+c.max.y};for(let e=0;e<o.length;e++){const n=o[e];for(let e=0;e<i.length;e++){const o=t.getTile(i[e]);if(!o||!o.hasData())continue;if(h(n,o.tileID))continue;const a=this._createProxiedId(n,o,s[n.key]&&s[n.key][t.id]),l=this.proxyToSource[n.key][t.id];l?l.push(a):this.proxyToSource[n.key][t.id]=[a],r.push(a);}}}_createProxiedId(t,i,s){let r=this.orthoMatrix;if(s){const e=s.find(e=>e.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const s=t.canonical.z-i.tileID.canonical.z;let o,n,a;r=e.Y();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;s>0?(o=e.a2>>s,n=o*((i.tileID.canonical.x<<s)-t.canonical.x+l),a=o*((i.tileID.canonical.y<<s)-t.canonical.y)):(o=e.a2<<-s,n=e.a2*(i.tileID.canonical.x-(t.canonical.x+l<<-s)),a=e.a2*(i.tileID.canonical.y-(t.canonical.y<<-s))),e.dr(r,0,o,0,o,0,1),e.bM(r,r,[n,a,0]);}return new xn(i.tileID,t.key,r)}_findTileCoveringTileID(t,i){let s=i.getTile(t);if(s&&s.hasData())return s;const r=this._findCoveringTileCache[i.id],o=r[t.key];if(s=o?i.getTileByID(o):null,s&&s.hasData()||null===o)return s;let n=s?s.tileID:t,a=n.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const r=i.getSource().maxzoom;if(t.canonical.z>=r){const s=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),n=new e.bP(a,t.wrap,r,t.canonical.x>>s,t.canonical.y>>s)):0!==s&&(a=r,n=new e.bP(a,t.wrap,r,t.canonical.x>>s,t.canonical.y>>s));}n.key!==t.key&&(c.push(n.key),s=i.getTile(n));}const h=e=>{c.forEach(t=>{r[t]=e;}),c.length=0;};for(a-=1;a>=l&&(!s||!s.hasData());a--){s&&h(s.tileID.key);const e=n.calculateScaledKey(a);if(s=i.getTileByID(e),s&&s.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):s=i.getTileByID(t);}return h(s?s.tileID.key:null),s&&s.hasData()?s:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function Tn(t,i,s){const r=function(t,i,s){const r=e.dF(i,t),o=e.dF(s,[.2126,.7152,.0722]),n=1-.3*Math.min(o,1),a=e.al(n,1,Math.min(r+1,1));return e.al(.92,1,Math.asin(e.b0(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.dC(o,s.slice(0,3),r);const n=[0,0,0];e.dC(n,i.slice(0,3),t[2]);const a=[0,0,0];return e.dD(a,o,n),e.dE(a)}const Sn=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Cn=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class En{static cacheKey(e,t,i,s){const r=[t];s&&r.push(s.cacheKey);for(const t of i)("string"==typeof t&&t.includes(" ")||e.usedDefines.has(t))&&r.push(t);return r.join("/")}constructor(t,i,s,r,o,n,a=!1){const l=t.gl;this.program=l.createProgram(),this._context=t,this._fixedUniformsFn=o,this._pending=!0,this._precompiled=a,this.attributes={},this.configuration=r,this.name=i,this.fixedDefines=[...n],a?t._compileStats.precompiled++:t._compileStats.onDemand++;const c=`#version 300 es\n${(r?r.defines():[]).concat(n.map(e=>`#define ${e}`)).join("\n")}`,h=[c,e.dG];for(const t of s.fragmentIncludes)h.push(e.ba[t]);h.push(s.fragmentSource);const d=h.join("\n"),u=[c,e.dH];for(const t of s.vertexIncludes)u.push(e.ba[t]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&s.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&u.push("uniform int u_instanceID;"),u.push(s.vertexSource);let p=u.join("\n");this.forceManualRenderingForInstanceIDShaders&&(p=p.replaceAll("gl_InstanceID","u_instanceID"));const f=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);l.shaderSource(f,d),l.compileShader(f),l.attachShader(this.program,f);const m=l.createShader(l.VERTEX_SHADER);if(l.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);l.shaderSource(m,p),l.compileShader(m),l.attachShader(this.program,m),l.linkProgram(this.program),this._fragmentShader=f,this._vertexShader=m,t.extParallelShaderCompile?t._pendingPrograms.add(this):this._finalize();}_finalize(){if(!this._pending)return;this._pending=!1;const t=this._context,i=t.gl;t._pendingPrograms.delete(this);const s=e.e.now(),r=i.getProgramParameter(this.program,i.LINK_STATUS),o=e.e.now()-s,n=t._compileStats;if(n.totalStallMs+=o,o>n.maxStallMs&&(n.maxStallMs=o),o>1){n.framesMissed+=Math.floor(60*o/1e3);const e=this.fixedDefines.join(",");n.stalls.push({name:`${this.name}${e?"/":""}${e}`,ms:o,timestamp:s});}if(this._fragmentShader&&(r||e.w(`Fragment shader '${this.name}': ${i.getShaderInfoLog(this._fragmentShader)}`),i.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(r||e.w(`Vertex shader '${this.name}': ${i.getShaderInfoLog(this._vertexShader)}`),i.deleteShader(this._vertexShader),this._vertexShader=null),!r)return e.w(`Failed to link program '${this.name}': ${i.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.aX(t)}))(t));const a=this.fixedDefines,l=this.name;(a.includes("TERRAIN")||a.includes("ELEVATED")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.aX(t),u_dem_prev:new e.aX(t),u_dem_tl:new e.a3(t),u_dem_scale:new e.a4(t),u_dem_tl_prev:new e.a3(t),u_dem_scale_prev:new e.a4(t),u_dem_size:new e.a4(t),u_dem_lerp:new e.a4(t),u_exaggeration:new e.a4(t),u_depth:new e.aX(t),u_depth_size_inv:new e.a3(t),u_depth_range_unpack:new e.a3(t),u_occluder_half_size:new e.a4(t),u_occlusion_depth_offset:new e.a4(t),u_meter_to_dem:new e.a4(t),u_label_plane_matrix_inv:new e.a5(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.a6(t),u_tile_tr_up:new e.a6(t),u_tile_br_up:new e.a6(t),u_tile_bl_up:new e.a6(t),u_tile_up_scale:new e.a4(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.a5(t),u_fog_range:new e.a3(t),u_fog_color:new e.aY(t),u_fog_horizon_blend:new e.a4(t),u_fog_vertical_limit:new e.a3(t),u_fog_temporal_offset:new e.a4(t),u_frustum_tl:new e.a6(t),u_frustum_tr:new e.a6(t),u_frustum_br:new e.a6(t),u_frustum_bl:new e.a6(t),u_globe_pos:new e.a6(t),u_globe_radius:new e.a4(t),u_globe_transition:new e.a4(t),u_is_globe:new e.aX(t),u_viewport:new e.a3(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=e.dI(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.a6(t),u_lighting_directional_dir:new e.a6(t),u_lighting_directional_color:new e.a6(t),u_ground_radiance:new e.a6(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=e.dJ(t));}maybeFinalize(){if(!this._pending)return;const e=this._context.extParallelShaderCompile;e&&!this._context.gl.getProgramParameter(this.program,e.COMPLETION_STATUS_KHR)||this._finalize();}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms());}getAttributeLocation(e,t){this._ensureReady();let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}_setUniformGroup(e,t,i){this._ensureReady();const s=this[t];if(!this.failedToCreate&&s){e.program.set(this.program);for(const e in i){const t=s[e];t&&t.set(this.program,e,i[e]);}}}setTerrainUniformValues(e,t){this._setUniformGroup(e,"terrainUniforms",t);}setGlobeUniformValues(e,t){this._setUniformGroup(e,"globeUniforms",t);}setFogUniformValues(e,t){this._setUniformGroup(e,"fogUniforms",t);}setCutoffUniformValues(e,t){this._setUniformGroup(e,"cutoffUniforms",t);}setLightsUniformValues(e,t){this._setUniformGroup(e,"lightsUniforms",t);}setShadowUniformValues(e,t){this._setUniformGroup(e,"shadowUniforms",t);}_drawDebugWireframe(t,i,s,r,o,n,a,l,c,h){const d=t.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;const u=t.context;if(!(()=>!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||t._terrain&&t._terrain.renderingToTexture||!Sn.includes(this.name))||!(!d.layers3D||!Cn.includes(this.name)))())return;const p=u.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,u);if(!f)return;const m=[...this.fixedDefines,"DEBUG_WIREFRAME"],_=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});_._ensureReady(),u.program.set(_.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const s in t[e])i[e][s]&&i[e][s].set(i.program,s,t[e][s].current);};c&&c.setUniforms(_.program,u,_.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,_),g("terrainUniforms",this,_),g("globeUniforms",this,_),g("fogUniforms",this,_),g("lightsUniforms",this,_),g("shadowUniforms",this,_),f.bind(),u.setColorMode(new e.a1([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.C.transparent,[!0,!0,!0,!1])),u.setDepthMode(new e.Z(i.func===p.LESS?p.LEQUAL:i.func,e.Z.ReadOnly,i.range)),u.setStencilMode(e._.disabled);const y=3*n.primitiveLength*2,v=3*n.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t<e;++t)_.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",t),p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,v);}else h&&h>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,v,h):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,v);o.bind(),u.program.set(this.program),u.setDepthMode(i),u.setStencilMode(s),u.setColorMode(r);}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const s of Object.keys(i))if(!i[s].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${s} not set but required by ${t} being defined`)}draw(e,t,i,s,r,o,n,a,l,c,h,d,u,p,f,m){const _=e.context,g=_.gl;if(this._ensureReady(),this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(s),_.setColorMode(r),_.setCullFace(o);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,n[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,d,{zoom:u});const y={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const v=f||[],b=p?p.getPaintVertexBuffers():[],x=t===g.TRIANGLES&&c,w=m&&m>0?1:void 0;for(const o of h.get()){const n=o.vaos||(o.vaos={});if((n[a]||(n[a]=new To)).bind(_,this,l,b,c,o.vertexOffset,v,w),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i<e;++i)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength);}else m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength);x&&this._drawDebugWireframe(e,i,s,r,c,o,d,u,p,m);}}}const In=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i,u_opacity_multiplier:1}),Dn=(t,i,s,r,o,n=0)=>Object.assign(In(t,i,o),e.dK(s,r,n)),Pn=(e,t,i,s)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:s,u_opacity_multiplier:1}),Ln=(e,t,i,s,r,o,n=0)=>Object.assign(Dn(e,t,i,s,o,n),{u_world:r}),Rn=(e,t,i)=>({u_image:e,u_texel_size:t,u_first_pass:i?1:0}),An=e.Y(),Mn=(t,i,s,r,o,n,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.dL(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.c5(s,1,n),d={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:An,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){d.u_inv_rot_matrix=r,d.u_merc_center=o,d.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],d.u_zoom_transition=e.S(l.zoom);const t=o[0]*e.a2,s=o[1]*e.a2;d.u_up_dir=l.projection.upVector(new e.bX(0,0,0),t,s);}return d};function Fn(t){const i=t.terrain?t.terrain.exaggeration():1;return (t.transform.pitch<15?e.al(.07,.7,e.b0((14-t.transform.zoom)/5,0,1)):.07)*i}const On=(t,i,s,r,o,n,a,l,c,h,d,u,p,f,m,_,g,y,v,b,x,w)=>({u_matrix:i,u_normalize_matrix:s,u_globe_matrix:r,u_merc_matrix:o,u_grid_matrix:n,u_tl_parent:a,u_scale_parent:d,u_fade_t:u.mix,u_opacity:u.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:e.dO(p.paint.get("raster-saturation")),u_contrast_factor:e.dN(p.paint.get("raster-contrast")),u_spin_weights:Bn(p.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:m,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:h,u_colorization_mix:Di(e.dM,g,v),u_colorization_offset:Pi(e.dM,y,v),u_color_ramp:_,u_color_ramp_size:e.dM,u_texture_offset:[x/(b+2*x),b/(b+2*x)],u_texture_res:[b+2*x,b+2*x],u_emissive_strength:w,u_zbias_factor:Fn(t)});function Bn(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 kn=e.Y(),zn=(t,i,s,r,o,n,a,l,c,h,d,u,p,f,m,_,g,y,v,b,x,w,T,S,C)=>{const E=o.transform,I={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:E.getCameraToCenterDistance(b),u_rotate_symbol:+s,u_aspect_ratio:E.width/E.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_is_sdf:+d,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:u,u_texsize_icon:p,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:kn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:kn,u_up_vector:[0,-1,0],u_color_adj_mat:T,u_icon_transition:S||0,u_gamma_scale:d?r?o.transform.getCameraToCenterDistance(b)*Math.cos(o.terrain?0:o.transform._pitch):1:0,u_device_pixel_ratio:e.e.devicePixelRatio,u_is_halo:1,u_scale_factor:C||1,u_ground_shadow_factor:x,u_inv_matrix:e.aO(e.Y(),a),u_normal_scale:w,u_lutTexture:e.dQ.LUT,u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0],u_spp_zoom_fraction:0,u_opacity_multiplier:1};return "globe"===b.name&&(I.u_tile_id=[m.canonical.x,m.canonical.y,1<<m.canonical.z],I.u_zoom_transition=_,I.u_inv_rot_matrix=y,I.u_merc_center=g,I.u_camera_forward=E._camera.forward(),I.u_ecef_origin=e.dP(E.globeMatrix,m.toUnwrapped()),I.u_tile_matrix=E.globeMatrix,I.u_up_vector=v),I},Un=(e,t,i,s)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:s}),Nn=(t,i,s,r,o,n,a,l,c)=>Object.assign(e.dR(o,n,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:s}),jn={fillExtrusion:e.dX,fillExtrusionPattern:e.dW,fill:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_ground_shadow_factor:new e.a6(t),u_opacity_multiplier:new e.a4(t)}),fillPattern:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_image:new e.aX(t),u_texsize:new e.a3(t),u_pixel_coord_upper:new e.a3(t),u_pixel_coord_lower:new e.a3(t),u_tile_units_to_pixels:new e.a4(t),u_ground_shadow_factor:new e.a6(t),u_pattern_transition:new e.a4(t),u_opacity_multiplier:new e.a4(t)}),fillOutline:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_world:new e.a3(t),u_ground_shadow_factor:new e.a6(t),u_opacity_multiplier:new e.a4(t)}),fillOutlinePattern:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_world:new e.a3(t),u_image:new e.aX(t),u_texsize:new e.a3(t),u_pixel_coord_upper:new e.a3(t),u_pixel_coord_lower:new e.a3(t),u_tile_units_to_pixels:new e.a4(t),u_ground_shadow_factor:new e.a6(t),u_pattern_transition:new e.a4(t),u_opacity_multiplier:new e.a4(t)}),lineBlendComposite:t=>({u_image:new e.aX(t),u_opacity:new e.a4(t),u_blend_mode:new e.aX(t),u_max_density:new e.a4(t)}),lineBlendReduce:t=>({u_image:new e.aX(t),u_texel_size:new e.a3(t),u_first_pass:new e.aX(t)}),circle:e.dV,collisionBox:t=>({u_matrix:new e.a5(t),u_inv_rot_matrix:new e.a5(t),u_camera_to_center_distance:new e.a4(t),u_extrude_scale:new e.a3(t),u_zoom_transition:new e.a4(t),u_merc_center:new e.a3(t),u_tile_id:new e.a6(t)}),collisionCircle:t=>({u_matrix:new e.a5(t),u_inv_matrix:new e.a5(t),u_camera_to_center_distance:new e.a4(t),u_viewport_size:new e.a3(t)}),debug:e.dU,clippingMask:t=>({u_matrix:new e.a5(t)}),heatmap:t=>({u_extrude_scale:new e.a4(t),u_intensity:new e.a4(t),u_matrix:new e.a5(t),u_inv_rot_matrix:new e.a5(t),u_merc_center:new e.a3(t),u_tile_id:new e.a6(t),u_zoom_transition:new e.a4(t),u_up_dir:new e.a6(t)}),heatmapTexture:t=>({u_image:new e.aX(t),u_color_ramp:new e.aX(t),u_opacity:new e.a4(t)}),hillshade:t=>({u_matrix:new e.a5(t),u_image:new e.aX(t),u_latrange:new e.a3(t),u_light:new e.a3(t),u_shadow:new e.dq(t),u_highlight:new e.dq(t),u_emissive_strength:new e.a4(t),u_accent:new e.dq(t)}),hillshadePrepare:t=>({u_matrix:new e.a5(t),u_image:new e.aX(t),u_dimension:new e.a3(t),u_zoom:new e.a4(t)}),line:e.dT,linePattern:e.dS,raster:t=>({u_matrix:new e.a5(t),u_normalize_matrix:new e.a5(t),u_globe_matrix:new e.a5(t),u_merc_matrix:new e.a5(t),u_grid_matrix:new e.aZ(t),u_tl_parent:new e.a3(t),u_scale_parent:new e.a4(t),u_fade_t:new e.a4(t),u_opacity:new e.a4(t),u_image0:new e.aX(t),u_image1:new e.aX(t),u_brightness_low:new e.a4(t),u_brightness_high:new e.a4(t),u_saturation_factor:new e.a4(t),u_contrast_factor:new e.a4(t),u_spin_weights:new e.a6(t),u_perspective_transform:new e.a3(t),u_raster_elevation:new e.a4(t),u_zoom_transition:new e.a4(t),u_merc_center:new e.a3(t),u_cutoff_params:new e.aY(t),u_colorization_mix:new e.aY(t),u_colorization_offset:new e.a4(t),u_color_ramp:new e.aX(t),u_color_ramp_size:new e.a4(t),u_texture_offset:new e.a3(t),u_texture_res:new e.a3(t),u_emissive_strength:new e.a4(t),u_zbias_factor:new e.a4(t)}),symbol:t=>({u_is_size_zoom_constant:new e.aX(t),u_is_size_feature_constant:new e.aX(t),u_size_t:new e.a4(t),u_size:new e.a4(t),u_camera_to_center_distance:new e.a4(t),u_rotate_symbol:new e.aX(t),u_aspect_ratio:new e.a4(t),u_fade_change:new e.a4(t),u_matrix:new e.a5(t),u_label_plane_matrix:new e.a5(t),u_coord_matrix:new e.a5(t),u_is_text:new e.aX(t),u_is_sdf:new e.aX(t),u_elevation_from_sea:new e.aX(t),u_pitch_with_map:new e.aX(t),u_texsize:new e.a3(t),u_texsize_icon:new e.a3(t),u_texture:new e.aX(t),u_texture_icon:new e.aX(t),u_gamma_scale:new e.a4(t),u_device_pixel_ratio:new e.a4(t),u_tile_id:new e.a6(t),u_zoom_transition:new e.a4(t),u_inv_rot_matrix:new e.a5(t),u_merc_center:new e.a3(t),u_camera_forward:new e.a6(t),u_tile_matrix:new e.a5(t),u_up_vector:new e.a6(t),u_ecef_origin:new e.a6(t),u_is_halo:new e.aX(t),u_icon_transition:new e.a4(t),u_color_adj_mat:new e.a5(t),u_scale_factor:new e.a4(t),u_ground_shadow_factor:new e.a6(t),u_inv_matrix:new e.a5(t),u_normal_scale:new e.a4(t),u_lutTexture:new e.aX(t),u_spp_fill_np_color:new e.aY(t),u_spp_halo_np_color:new e.aY(t),u_spp_opacity:new e.a4(t),u_spp_halo_width:new e.a4(t),u_spp_halo_blur:new e.a4(t),u_spp_emissive_strength:new e.a4(t),u_spp_occlusion_opacity:new e.a4(t),u_spp_z_offset:new e.a4(t),u_spp_translate_rotation:new e.a3(t),u_spp_zoom_fraction:new e.a4(t),u_opacity_multiplier:new e.a4(t)}),background:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_opacity:new e.a4(t),u_color:new e.dq(t)}),backgroundPattern:t=>({u_matrix:new e.a5(t),u_emissive_strength:new e.a4(t),u_opacity:new e.a4(t),u_image:new e.aX(t),u_pattern_tl:new e.a3(t),u_pattern_br:new e.a3(t),u_texsize:new e.a3(t),u_pattern_size:new e.a3(t),u_pixel_coord_upper:new e.a3(t),u_pixel_coord_lower:new e.a3(t),u_pattern_units_to_pixels:new e.a3(t)}),terrainRaster:t=>({u_matrix:new e.a5(t),u_image0:new e.aX(t),u_image1:new e.aX(t),u_skirt_height:new e.a4(t),u_ground_shadow_factor:new e.a6(t),u_emissive_texture_available:new e.a4(t)}),skybox:t=>({u_matrix:new e.a5(t),u_sun_direction:new e.a6(t),u_cubemap:new e.aX(t),u_opacity:new e.a4(t),u_temporal_offset:new e.a4(t)}),skyboxGradient:t=>({u_matrix:new e.a5(t),u_color_ramp:new e.aX(t),u_center_direction:new e.a6(t),u_radius:new e.a4(t),u_opacity:new e.a4(t),u_temporal_offset:new e.a4(t)}),skyboxCapture:t=>({u_matrix_3f:new e.aZ(t),u_sun_direction:new e.a6(t),u_sun_intensity:new e.a4(t),u_color_tint_r:new e.aY(t),u_color_tint_m:new e.aY(t),u_luminance:new e.a4(t)}),globeRaster:t=>({u_proj_matrix:new e.a5(t),u_globe_matrix:new e.a5(t),u_normalize_matrix:new e.a5(t),u_merc_matrix:new e.a5(t),u_zoom_transition:new e.a4(t),u_merc_center:new e.a3(t),u_image0:new e.aX(t),u_image1:new e.aX(t),u_grid_matrix:new e.aZ(t),u_skirt_height:new e.a4(t),u_far_z_cutoff:new e.a4(t),u_frustum_tl:new e.a6(t),u_frustum_tr:new e.a6(t),u_frustum_br:new e.a6(t),u_frustum_bl:new e.a6(t),u_globe_pos:new e.a6(t),u_globe_radius:new e.a4(t),u_viewport:new e.a3(t),u_emissive_texture_available:new e.a4(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.a6(t),u_frustum_tr:new e.a6(t),u_frustum_br:new e.a6(t),u_frustum_bl:new e.a6(t),u_horizon:new e.a4(t),u_transition:new e.a4(t),u_fadeout_range:new e.a4(t),u_atmosphere_fog_color:new e.aY(t),u_high_color:new e.aY(t),u_space_color:new e.aY(t),u_temporal_offset:new e.a4(t),u_horizon_angle:new e.a4(t)}),stars:t=>({u_matrix:new e.a5(t),u_up:new e.a6(t),u_right:new e.a6(t),u_intensity_multiplier:new e.a4(t)}),occlusion:t=>({u_matrix:new e.a5(t),u_anchorPos:new e.a6(t),u_screenSizePx:new e.a3(t),u_occluderSizePx:new e.a3(t),u_color:new e.aY(t)})};class Vn{constructor(e,t,i,s){this.id=Vn.uniqueIdxCounter,Vn.uniqueIdxCounter++,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||s||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=Vn.uniqueIdxCounter,Vn.uniqueIdxCounter++;const t=this.context.gl;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);}}Vn.uniqueIdxCounter=0;const Gn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class qn{constructor(e,t,i,s,r,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=s,this.instanceCount=o,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||r||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){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 s=t.getAttributeLocation(e,i.name);-1!==s&&e.enableVertexAttribArray(s);}}setVertexAttribPointers(e,t,i){for(const s of this.attributes){const r=t.getAttributeLocation(e,s.name);if(-1!==r){const t=s.offset+this.itemSize*(i||0);"Float32"===s.type?e.vertexAttribPointer(r,s.components,e.FLOAT,!1,this.itemSize,t):e.vertexAttribIPointer(r,s.components,e[Gn[s.type]],this.itemSize,t);}}}setVertexAttribDivisor(e,t,i){for(let s=0;s<this.attributes.length;s++){const r=t.getAttributeLocation(e,this.attributes[s].name);-1!==r&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(r,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Zn{constructor(e,t,i,s,r){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();s>0&&(this.colorAttachment0=new ln(e,o,0)),s>1&&(this.colorAttachment1=new ln(e,o,1)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new cn(e,o):new hn(e,o));}static createWithTexture(t,i,s,r,o){const n=t.gl;if(t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,s,r]),i&&i.width===s&&i.height===r)return n.bindTexture(n.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();const a=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,l=new e.T(t,{width:s,height:r,data:null},a);l.bind(n.LINEAR,n.CLAMP_TO_EDGE);const c=t.createFramebuffer(s,r,1,null);if(c.format=a,c.colorAttachment0.set(l.texture),o){const e=t.createRenderbuffer(n.DEPTH24_STENCIL8,s,r);t.bindFramebuffer.set(c.framebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),c._stencilRbo=e;}return c}createColorAttachment(e,t){0===t?this.colorAttachment0=new ln(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new ln(e,this.framebuffer,1));}removeColorAttachment(e,t){const i=this.context.gl;let s;0===t?(s=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(s=this.colorAttachment1.get(),this.colorAttachment1=void 0),s&&i.deleteTexture(s);}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t);}if(this.colorAttachment1){const t=this.colorAttachment1.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}this._stencilRbo&&(e.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),e.deleteFramebuffer(this.framebuffer);}}class $n{constructor(e,t){this.gl=e,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new Po(this),this.clearDepth=new Lo(this),this.clearStencil=new Ro(this),this.colorMask=new Ao(this),this.depthMask=new Mo(this),this.stencilMask=new Fo(this),this.stencilFunc=new Oo(this),this.stencilOp=new Bo(this),this.stencilTest=new ko(this),this.depthRange=new zo(this),this.depthTest=new Uo(this),this.depthFunc=new No(this),this.blend=new jo(this),this.blendFunc=new Vo(this),this.blendColor=new Go(this),this.blendEquation=new qo(this),this.cullFace=new Zo(this),this.cullFaceSide=new $o(this),this.frontFace=new Ho(this),this.program=new Wo(this),this.activeTexture=new Xo(this),this.viewport=new Ko(this),this.bindFramebuffer=new Yo(this),this.bindRenderbuffer=new Qo(this),this.bindTexture=new Jo(this),this.bindVertexBuffer=new en(this),this.bindElementBuffer=new tn(this),this.bindVertexArrayOES=new sn(this),this.pixelStoreUnpack=new rn(this),this.pixelStoreUnpackPremultiplyAlpha=new on(this),this.pixelStoreUnpackFlipY=new nn(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=e.getExtension("EXT_color_buffer_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=e.getExtension("KHR_parallel_shader_compile");}sweepPendingPrograms(){if(0!==this._pendingPrograms.size)for(const e of this._pendingPrograms)e.maybeFinalize();}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new Vn(this,e,t,i)}createVertexBuffer(e,t,i,s,r){return new qn(this,e,t,i,s,r)}createRenderbuffer(e,t,i){const s=this.gl,r=s.createRenderbuffer();return this.bindRenderbuffer.set(r),s.renderbufferStorage(s.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,s){return new Zn(this,e,t,i,s)}clear({color:e,depth:t,stencil:i,colorMask:s}){const r=this.gl;let o=0;e&&(o|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(s||[!0,!0,!0,!0])),void 0!==t&&(o|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(o);}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(t){e.O(t.blendFunction,e.a1.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}const Hn=e.Y();function Wn(t){const i=t._camera.getWorldToCamera(t.worldSize,1),s=e.X([],i,t.globeMatrix);e.aO(s,s);const r=[0,0,0],o=[0,1,0,0];return e.c7(o,o,s),r[0]=o[0],r[1]=o[1],r[2]=o[2],e.c3(r,r),r}function Xn({width:t,height:i,anchor:s,textOffset:r,textScale:o},n){const{horizontalAlign:a,verticalAlign:l}=e.cM(s),c=-(a-.5)*t,h=-(l-.5)*i,d=e.cN(s,r);return new e.P((c/o+d[0])*n,(h/o+d[1])*n)}function Kn(t,i,s,r,o,n,a,l,c,h){const d=t.text.placedSymbolArray,u=t.text.dynamicLayoutVertexArray,p=t.icon.dynamicLayoutVertexArray,f={},m=t.getProjection(),_=vt(a,m,o),g=o.elevation,y=m.upVectorScale(a.canonical,o.center.lat,o.worldSize).metersToTile;u.clear();for(let p=0;p<d.length;p++){const v=d.get(p),{tileAnchorX:b,tileAnchorY:x,numGlyphs:w}=v,T=v.hidden||!v.crossTileID||t.allowVerticalPlacement&&!v.placedOrientation?null:r[v.crossTileID];if(T){let r=0,d=0,S=0;const C="road"===t.elevationType;if(g||C){const i=new e.P(b,x);let s=0;if(C&&t.hdExt){const r=t.symbolInstances.get(t.text.symbolInstanceIndices[p]);if(t.hdExt.isCrossTileRoadElevation(r.elevationFeatureIndex,a.canonical)){const e=t.hdExt.getRoadFeatureHeightForPlacedSymbol(t,t.text,p,i,a.canonical);s=null!==e?e:0;}else {const r=t.hdExt.getElevationFeatureForPlacedSymbol(t,t.text,p);s=e.cW.getAtTileOffset(a,i,g,void 0!==r?r:null);}}else s=e.cW.getAtTileOffset(a,i,g,null);const[o,n,l]=m.upVector(a.canonical,b,x);r=s*o*y,d=s*n*y,S=s*l*y;}let[E,I,D,P]=e.cX(v.projectedAnchorX+r,v.projectedAnchorY+d,v.projectedAnchorZ+S,s?_:n);const L=e.d_(o.getCameraToCenterDistance(m),P);let R=e.d4(t.textSizeData,c,v)*L/e.d1;s&&(R*=t.tilePixelRatio/l);const A=Xn(T,R);s?(({x:E,y:I,z:D}=m.projectTilePoint(b+A.x,x+A.y,a.canonical)),[E,I,D]=e.cX(E+r,I+d,D+S,n)):(i&&A._rotate(-o.angle),E+=A.x,I+=A.y,D=0);const M=t.allowVerticalPlacement&&v.placedOrientation===e.cL.vertical?Math.PI/2:0;for(let t=0;t<w;t++)e.d$(u,E,I,D,M);h&&v.associatedIconIndex>=0&&(f[v.associatedIconIndex]={x:E,y:I,z:D,angle:M});}else e.dZ(w,u);}if(h){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const s=i.get(t),{numGlyphs:r}=s,o=f[t];if(s.hidden||!o)e.dZ(r,p);else {const{x:t,y:i,z:s,angle:n}=o;for(let o=0;o<r;o++)e.d$(p,t,i,s,n);}}t.icon.dynamicLayoutVertexBuffer.updateData(p);}t.text.dynamicLayoutVertexBuffer.updateData(u);}function Yn(t,i,s,r,o,n,a={}){const l=s.paint.get("icon-translate"),c=s.paint.get("text-translate"),h=s.paint.get("icon-translate-anchor"),d=s.paint.get("text-translate-anchor"),u=s.layout.get("icon-rotation-alignment"),p=s.layout.get("text-rotation-alignment"),f=s.layout.get("icon-pitch-alignment"),m=s.layout.get("text-pitch-alignment"),_=s.layout.get("icon-keep-upright"),g=s.layout.get("text-keep-upright"),y=s.paint.get("icon-color-saturation"),v=s.paint.get("icon-color-contrast"),b=s.paint.get("icon-color-brightness-min"),x=s.paint.get("icon-color-brightness-max"),w="sea"===s.layout.get("symbol-elevation-reference"),T="none"===s.layout.get("icon-image-use-theme"),S=t.context,C=S.gl,E=t.transform,I="map"===u,D="map"===p,P="map"===f,L="map"===m,R=void 0!==s.layout.get("symbol-sort-key").constantOr(1);let A=!1;const M=t.depthModeForSublayer(0,e.Z.ReadOnly),F=new e.Z(t.context.gl.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D),O=[e.a7(E.center.lng),e.a8(E.center.lat)],B=s.layout.get("text-variable-anchor"),k="globe"===E.projection.name,z=[],U=[0,-1,0];for(const o of r){const r=i.getTile(o),n=r.getBucket(s);if(!n)continue;if("mercator"===n.projection.name&&k)continue;if(n.fullyClipped)continue;const u="globe"===n.projection.name,p=u?e.S(E.zoom):0,f=vt(o,n.getProjection(),E),m=E.calculatePixelsToTileUnitsMatrix(r),N=B&&n.hasTextData(),j=n.hasIconTextFit()&&N&&n.hasIconData(),V=n.getProjection().createInversionMatrix(E,o.canonical),G=(1<<r.tileID.canonical.z)*e.a2/t.transform.worldSize,q=i=>{let s=[0,0,0];if(i){const i=t.style.directionalLight,r=t.style.ambientLight;i&&r&&(s=e.aF(t.style,i,r));}return s},Z=e=>{const i=Math.floor(t.context.maxUniformBlockSize/4),s=Math.floor(i/4);e.push(`MAX_UBO_SIZE_VEC4 ${s}u`);},$=e=>{E.depthOcclusionForSymbolsAndCircles&&(s.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},H=i=>{s.lut&&!T&&(s.lut.texture||(s.lut.texture=new e.e1(t.context,s.lut.image,[s.lut.image.height,s.lut.image.height,s.lut.image.height],S.gl.RGBA8)),S.activeTexture.set(S.gl.TEXTURE0+e.dQ.LUT),s.lut.texture&&s.lut.texture.bind(S.gl.LINEAR,S.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"));},W=()=>{const i=I&&"point"!==s.layout.get("symbol-placement"),a=[];$(a),H(a);const c=i||j,d="road"===n.elevationType,g=t.shadowRenderer,T=d&&P&&!!g&&g.enabled,S=q(T),D=d&&P&&!t.terrain?F:M,L=s.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&P&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),L>0&&n.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!n.icon.zOffsetVertexBuffer||d&&t.terrain||a.push("Z_OFFSET"),0===y&&0===v&&0===b&&1===x||a.push("COLOR_ADJUSTMENT"),T&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),d&&P&&!t.terrain&&n.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Z(a);const R=t.getOrCreateProgram("symbol",{defines:a}),A=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],B=n.iconSizeData,z=e.cG(B,E.zoom),N=P||!E.isOrthographic,W=e.dY(f,r.tileID.canonical,P,I,E,n.getProjection(),m),X=e.cF(f,r.tileID.canonical,P,I,E,n.getProjection(),m),K=n.icon.uboBinder&&n.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:l,Y=t.translatePosMatrix(X,r,K,h,!0),Q=t.translatePosMatrix(f,r,K,h),J=c?Hn:W,ee=I&&!P&&!i;let te=U;!k&&!E.mercatorFromTransition||I||(te=Wn(E));const ie=u?te:U,se=s.getColorAdjustmentMatrix(y,v,b,x),re=zn(B.kind,z,ee,P,t,Q,J,Y,w,!1,n.sdfIcons,A,[0,0],0,o,p,O,V,ie,n.getProjection(),S,G,se,L,null),oe=r.imageAtlasTexture?r.imageAtlasTexture:null,ne=1!==s.layout.get("icon-size").constantOr(0)||n.iconsNeedLinear,ae=n.sdfIcons||t.options.rotating||t.options.zooming||ne||N?C.LINEAR:C.NEAREST,le=n.sdfIcons&&0!==s.paint.get("icon-halo-width").constantOr(1),ce=t.terrain&&P&&i?e.aO(e.Y(),W):Hn;if(i&&n.icon){const i=e.cW.getAtTileOffsetFunc(o,E.center.lat,E.worldSize,n.getProjection()),a=e.cE(f,r.tileID.canonical,P,I,E,n.getProjection(),m),l=s.layout.get("icon-size-scale-range"),c=e.b0(t.scaleFactor,l[0],l[1]);e.e0(n,f,t,!1,a,X,P,_,i,o,c);}return {program:R,buffers:n.icon,uniformValues:re,atlasTexture:oe,atlasTextureIcon:null,atlasInterpolation:ae,atlasInterpolationIcon:null,isSDF:n.sdfIcons,hasHalo:le,depthMode:D,tile:r,renderWithShadows:T,labelPlaneMatrixInv:ce}},X=()=>{const i=D&&"point"!==s.layout.get("symbol-placement"),a=[],l=i||B||j,h="road"===n.elevationType,_=t.shadowRenderer,y=h&&L&&!!_&&_.enabled,v=q(y),b=h&&L&&!t.terrain?F:M;t.terrainRenderModeElevated()&&L&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!n.text.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),n.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),y&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),h&&L&&!t.terrain&&n.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),$(a),Z(a);const x=t.getOrCreateProgram("symbol",{defines:a});let T,S=[0,0],I=null;const P=n.textSizeData;n.iconsInText&&(S=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],I=r.imageAtlasTexture?r.imageAtlasTexture:null,T=L||!E.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?C.LINEAR:C.NEAREST);const R=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],A=s.layout.get("text-size-scale-range"),z=e.b0(t.scaleFactor,A[0],A[1]),N=e.cG(P,E.zoom,z),H=e.dY(f,r.tileID.canonical,L,D,E,n.getProjection(),m),W=e.cF(f,r.tileID.canonical,L,D,E,n.getProjection(),m),X=n.text.uboBinder&&n.text.uboBinder.hasPerFeatureTranslate()?[0,0]:c,K=t.translatePosMatrix(W,r,X,d,!0),Y=t.translatePosMatrix(f,r,X,d),Q=l?Hn:H,J=D&&!L&&!i;let ee=U;!k&&!E.mercatorFromTransition||D||(ee=Wn(E));const te=zn(P.kind,N,J,L,t,Y,Q,K,w,!0,!0,R,S,0,o,p,O,V,u?ee:U,n.getProjection(),v,G,null,null,z),ie=r.glyphAtlasTexture?r.glyphAtlasTexture:null,se=C.LINEAR,re=0!==s.paint.get("text-halo-width").constantOr(1),oe=t.terrain&&L&&i?e.aO(e.Y(),H):Hn;if(i&&n.text){const i=e.cW.getAtTileOffsetFunc(o,E.center.lat,E.worldSize,n.getProjection()),s=e.cE(f,r.tileID.canonical,L,D,E,n.getProjection(),m);e.e0(n,f,t,!0,s,W,L,g,i,o,z);}return {program:x,buffers:n.text,uniformValues:te,atlasTexture:ie,atlasTextureIcon:I,atlasInterpolation:se,atlasInterpolationIcon:T,isSDF:!0,hasHalo:re,depthMode:b,tile:r,renderWithShadows:y,labelPlaneMatrixInv:oe}},K=n.icon.segments.get().length,Y=n.text.segments.get().length,Q=K&&!a.onlyText?W():null,J=Y&&!a.onlyIcons?X():null,ee=s.paint.get("icon-opacity").constantOr(1),te=s.paint.get("text-opacity").constantOr(1);if(R&&n.canOverlap){A=!0;const t=ee&&!a.onlyText?n.icon.segments.get():[],i=te&&!a.onlyIcons?n.text.segments.get():[];for(const i of t)z.push({segments:new e.ac([i]),sortKey:i.sortKey,state:Q});for(const t of i)z.push({segments:new e.ac([t]),sortKey:t.sortKey,state:J});}else a.onlyText||z.push({segments:ee?n.icon.segments:new e.ac([]),sortKey:0,state:Q}),a.onlyIcons||z.push({segments:te?n.text.segments:new e.ac([]),sortKey:0,state:J});}A&&z.sort((e,t)=>e.sortKey-t.sortKey);for(const e of z){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:E.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(E.depthOcclusionForSymbolsAndCircles,i.program),S.activeTexture.set(C.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,C.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(S.activeTexture.set(C.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,C.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Qn(i.buffers,e.segments,s,t,i.program,i.depthMode,o,n,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Qn(i.buffers,e.segments,s,t,i.program,i.depthMode,o,n,r,1)),r.u_is_halo=0;}Qn(i.buffers,e.segments,s,t,i.program,i.depthMode,o,n,i.uniformValues,1);}}}function Qn(t,i,s,r,o,n,a,l,c,h){const d=r.context,u=d.gl,p=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.iconTransitioningVertexBuffer,t.globeExtVertexBuffer,t.zOffsetVertexBuffer,t.orientationVertexBuffer];t.featureIdBuffer&&p.push(t.featureIdBuffer);const f=t.uboBinder?null:t.programConfigurations.get(s.id);if(t.uboBinder){t.uboBinder.layer=s;const e=r.transform.zoom,i=r.style.getBrightness?r.style.getBrightness():null,o=t.uboBinder.getConstantUniformValues(e,i);c.u_spp_fill_np_color=o.fill_np_color,c.u_spp_halo_np_color=o.halo_np_color,c.u_spp_opacity=o.opacity,c.u_spp_halo_width=o.halo_width,c.u_spp_halo_blur=o.halo_blur,c.u_spp_emissive_strength=o.emissive_strength,c.u_spp_occlusion_opacity=o.occlusion_opacity,c.u_spp_z_offset=o.z_offset,c.u_spp_zoom_fraction=e-t.uboBinder._floorZoom;const n=s.paint.get(t.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),a=t.uboBinder.hasPerFeatureTranslate()&&"map"===n?r.transform.angle:0;c.u_spp_translate_rotation=[Math.cos(a),Math.sin(a)];}const{batchIndices:m,batchSegments:_}=t.getBatchGrouping(i);for(const i of m){const m=_.get(i);t.uboBinder&&t.uboBinder.bind(d,o.program,i),o.draw(r,u.TRIANGLES,n,a,l,e.$.disabled,c,s.id,t.layoutVertexBuffer,t.indexBuffer,m,s.paint,r.transform.zoom,f,p,h);}}function Jn(t,i,s,r,o,n){const a=s.paint.get("line-width"),l=s.paint.get("line-emissive-strength").isConstant(),c=s.paint.get("line-emissive-strength").constantOr(0),h=s.paint.get("line-occlusion-opacity"),d=s.layout.get("line-elevation-reference"),u="meters"===s.layout.get("line-width-unit"),p="sea"===d,f=!(!t.terrain||!t.terrain.enabled),m=t.context,_=m.gl;if(s.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const g=s.layout.get("line-cross-slope"),y=void 0!==g,v=g<1,b=o||t.colorModeForDrapableLayerRenderPass(l?c:null),x=t.terrain&&t.terrain.renderingToTexture||n,w=x?1:e.e.devicePixelRatio,T=s.paint.get("line-dasharray"),S=T.constantOr(1),C=s.layout.get("line-cap"),E=T.constantOr(null),I=C.constantOr(null),D=s.paint.get("line-pattern"),P=D.constantOr(1),L=s.paint.get("line-pattern-cross-fade"),R=D.constantOr(null),A=s.paint.get("line-opacity").constantOr(1);let M=!P&&1!==A||t.depthOcclusion&&h>0&&h<1;const F=s.paint.get("line-gradient"),O=0!==s.paint.get("line-border-width").constantOr(1)?s.paint.get("line-border-gradient"):null,B=P?"linePattern":"line",k=e.e4(s);let z;if(x&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(M=!1),0!==h&&t.depthOcclusion){const t=s.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?z=t.value:e.w(`Occlusion opacity for layer ${s.id} is supported only when line-opacity isn't data-driven.`);}"constant"!==a.value.kind&&!1===a.value.isLineProgressConstant&&k.push("VARIABLE_LINE_WIDTH");const U=s.paint.get("line-emissive-strength");P||"constant"===U.value.kind||!1!==U.value.isLineProgressConstant||k.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),t._debugParams.showElevationIdDebug&&k.push("DEBUG_ELEVATION_ID"),x&&("dual-source-blending"!==t.emissiveMode||l?"mrt-fallback"===t.emissiveMode&&k.push("USE_MRT1"):k.push("DUAL_SOURCE_BLENDING"));const N={},j=[],V=(r,o,n,a,l,c)=>{for(const d of r){const r=i.getTile(d);if(P&&!r.patternsLoaded())continue;const p=r.getBucket(s);if(!p)continue;if("none"!==p.elevationType&&!l||"none"===p.elevationType&&l)continue;t.prepareDrawTile();const f=[...o],g="road"===p.elevationType,y=t.shadowRenderer,v=g&&!!y&&y.enabled;let T=[0,0,0];if(v){const i=t.style.directionalLight,s=t.style.ambientLight;i&&s&&(T=e.aF(t.style,i,s)),f.push("RENDER_SHADOWS","NORMAL_OFFSET");}const C=p.programConfigurations.get(s.id);let D=!1;if(R&&r.imageAtlas){const t=e.aG.from(R),i=t.getPrimary().scaleSelf(w).toString(),s=r.imageAtlas.patternPositions.get(i),o=t.getSecondary(),n=o?r.imageAtlas.patternPositions.get(o.scaleSelf(w).toString()):null;D=!!s&&!!n,s&&C.setConstantPatternPositions(s,n);}L>0&&(D||C.getPatternTransitionVertexBuffer("line-pattern"))&&f.push("LINE_PATTERN_TRANSITION"),p.elevationGroundScaleVertexBuffer&&f.push("ELEVATION_GROUND_SCALE");const k=t.isTileAffectedByFog(d),U=t.getOrCreateProgram(B,{config:C,defines:f,overrideFog:k});if(!P&&E&&I&&r.lineAtlas){const e=r.lineAtlas.getDash(E,I);e&&C.setConstantPatternPositions(e);}v&&y.setupShadows(r.tileID.toUnwrapped(),U,"vector-tile");let[V,G]=s.paint.get("line-trim-offset");if("round"===I||"square"===I){const e=1;V!==G&&(0===V&&(V-=e),1===G&&(G+=e));}const q=x?d.projMatrix:null,Z=u?1/p.tileToMeter/e.c5(r,1,t.transform.zoom):1,$=u?1/p.tileToMeter/e.c5(r,1,Math.floor(t.transform.zoom)):1,H=S?s.paint._values["line-floorwidth"]:null;let W;const X=r.dashIdealZ;if(H&&"constant"===H.value.kind&&X!==r.tileID.overscaledZ){const e=p.zoom;e in N||(N[e]=Math.max(.01,s.widthExpression().evaluate({zoom:e}))),W=H.value.value,H.value.value=N[e]*Math.pow(2,X-e);}const K=P?e.e5(t,r,s,q,w,Z,$,[V,G],T,L):e.e6(t,r,s,q,p.lineClipsArray.length,w,Z,$,[V,G],T),Y=(r,o,n,a,l,c)=>{let h=r.texture;if(o!==r.version){let c=256;if(n){const s=i.getSource().maxzoom,r=d.canonical.z===s?Math.ceil(1<<t.transform.maxZoom-d.canonical.z):1;c=e.b0(e.e7(p.maxLineLength/e.a2*1024*r),256,m.maxTextureSize);}r.gradient=e.e8({expression:a,evaluationKey:"lineProgress",resolution:c,image:r.gradient||void 0,clips:p.lineClipsArray,lut:l?null:s.lut}),r.texture?r.texture.update(r.gradient):r.texture=new e.T(m,r.gradient,_.RGBA8),r.version=o,h=r.texture;}m.activeTexture.set(c),h.bind(n?_.NEAREST:_.LINEAR,_.CLAMP_TO_EDGE);};F&&Y(p.gradients[s.id],s.gradientVersion,s.stepInterpolant,s.gradientExpression(),"none"===s.paint.get("line-gradient-use-theme").constantOr("default"),_.TEXTURE1),O&&Y(p.borderGradients[s.id],s.borderGradientVersion,s.borderStepInterpolant,s.borderGradientExpression(),"none"===s.paint.get("line-border-gradient-use-theme").constantOr("default"),_.TEXTURE2),S&&(m.activeTexture.set(_.TEXTURE0),r.lineAtlasTexture&&r.lineAtlasTexture.bind(_.LINEAR,_.REPEAT),C.updatePaintBuffers()),P&&(m.activeTexture.set(_.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),C.updatePaintBuffers()),l&&!g&&t.terrain.setupElevationDraw(r,U),t.uploadCommonUniforms(m,U,d.toUnwrapped());const Q=Xs.drawLineFrcCoverageDetect?Xs.drawLineFrcCoverageDetect(t,p,d,l,K,C,U,n,b,j):null,J=(i,r,o)=>{r&&0!==r.get().length&&(null!=z&&(z.value=A*h),void 0!==o&&(K.u_opacity_multiplier=o),U.draw(t,_.TRIANGLES,n,i,b,e.$.disabled,K,s.id,p.layoutVertexBuffer,p.indexBuffer,r,s.paint,t.transform.zoom,C,[p.layoutVertexBuffer2,p.patternVertexBuffer,p.zOffsetVertexBuffer,p.elevationIdColVertexBuffer,p.elevationGroundScaleVertexBuffer]),void 0!==o&&(K.u_opacity_multiplier=1),null!=z&&(z.value=A));},ee=e=>{Q&&Q.active&&Xs.drawLineFrcRenderLine?Xs.drawLineFrcRenderLine(p,Q,e,J):J(e,p.segments);};if(M&&!l){const i=t.stencilModeForClipping(d).ref;0===i&&x&&m.clear({stencil:0});const s={func:_.EQUAL,mask:255};K.u_alpha_discard_threshold=.8,ee(new e._(s,i,255,_.KEEP,_.KEEP,_.INVERT)),K.u_alpha_discard_threshold=0,ee(new e._(s,i,255,_.KEEP,_.KEEP,_.KEEP));}else K.u_alpha_discard_threshold=M&&l&&c?.8:0,ee(l?a:t.stencilModeForClipping(d));Q&&Xs.drawLineFrcFadePass&&Xs.drawLineFrcFadePass(t,p,d,Q,l,a,J),void 0!==W&&(H.value.value=W);}};let G=t.depthModeForSublayer(0,e.Z.ReadOnly);const q=new e.Z(t.depthOcclusion?_.GREATER:_.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D);if(s.hasNonElevatedBuckets){const i=!x&&t.terrain;0!==h&&i?e.w(`Occlusion opacity for layer ${s.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${s.id}.`):V(r,k,G,e._.disabled,!1,!0);}if(s.hasElevatedBuckets){"hd-road-markup"===d?f||(G=q,k.push("ELEVATED_ROADS")):(k.push("ELEVATED"),G=q,y&&k.push(v?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),p&&k.push("ELEVATION_REFERENCE_SEA"));const i=M?t.stencilModeFor3D():e._.disabled;"hd-road-markup"!==d&&(t.forceTerrainMode=!0),V(r,k,G,i,!0,!0),M&&V(r,k,G,i,!0,!1),"hd-road-markup"!==d&&(t.forceTerrainMode=!1);}Xs.drawLineFrcCoverageSecondPass&&Xs.drawLineFrcCoverageSecondPass(t,s,j),M&&(t.resetStencilClippingMasks(),x&&m.clear({stencil:0})),0===h||t.depthOcclusion||x||t.layersWithOcclusionOpacity.push(t.currentLayer);}class ea{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null);}}class ta{constructor(e){this.pbo=e.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0;}destroy(e){this.sync&&(e.deleteSync(this.sync),this.sync=null),e.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null);}}const ia={additive:{clearColor:new e.C(0,0,0,0),colorMode:e.a1.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new e.C(1,1,1,1),colorMode:e.a1.multiply,compositeUniformValue:0}};function sa(e){return !(!e.extRenderToTextureHalfFloat&&!e.extColorBufferFloat)}function ra(t,i){return "additive"===t&&sa(i)?e.a1.additiveAlphaWeightedUnboundedAlpha:ia[t].colorMode}function oa(t,i,s){const r=t.context,o=r.gl;let n=s.width,a=s.height,l=s.colorAttachment0.get();i.lineBlendDensityReadback||(i.lineBlendDensityReadback=new ta(o));const c=i.lineBlendDensityReadback;let h=0,d=!0;for(;n>1||a>1;){const s=Math.max(1,Math.floor(n/2)),u=Math.max(1,Math.floor(a/2)),p=0===h?"fboA":"fboB";c[p]=Zn.createWithTexture(r,c[p],s,u,!1);const f=c[p];r.bindFramebuffer.set(f.framebuffer),r.viewport.set([0,0,s,u]),r.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,l),t.getOrCreateProgram("lineBlendReduce").draw(t,o.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.unblended,e.$.disabled,Rn(0,[1/n,1/a],d),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom),n=s,a=u,l=f.colorAttachment0.get(),h=1-h,d=!1;}const u=sa(r),p=u?16:4;c.sync&&(o.deleteSync(c.sync),c.sync=null),o.bindBuffer(o.PIXEL_PACK_BUFFER,c.pbo),o.bufferData(o.PIXEL_PACK_BUFFER,p,o.STREAM_READ),o.readPixels(0,0,1,1,o.RGBA,u?o.FLOAT:o.UNSIGNED_BYTE,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),c.sync=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0),r.viewport.set([0,0,t.width,t.height]);}function na(e,t,i){if(!sa(e.context))return;const s=t.lineBlendDensityReadback;s&&s.sync?(function(e,t,i){if(e.sync&&t.getSyncParameter(e.sync,t.SYNC_STATUS)===t.SIGNALED){if(t.deleteSync(e.sync),e.sync=null,t.bindBuffer(t.PIXEL_PACK_BUFFER,e.pbo),sa(i)){const i=new Float32Array(4);t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,i);const s=i[1];e.maxDensity=Math.max(2*(s>0?i[0]/s:0),1);}else e.maxDensity=1;t.bindBuffer(t.PIXEL_PACK_BUFFER,null);}}(s,e.context.gl,e.context),s.sync||(oa(e,t,i),e.style.map.triggerRepaint())):(oa(e,t,i),e.style.map.triggerRepaint());}function aa(t,i,s,r,o,n){const a=t.context,l=a.gl,c="additive"===s?1:i.paint.get("line-opacity").constantOr(1),h="additive"===s?function(e,t){const i=t.paint.get("line-blend-additive-clamp");if(i>0)return i;const s=t.lineBlendDensityReadback;return s&&0!==s.maxDensity?s.maxDensity:null}(0,i):1;if(null===h)return;a.bindFramebuffer.set(o),n&&a.viewport.set([0,0,n[0],n[1]]),a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,r.colorAttachment0.get());const d=ra(s,t.context);t.getOrCreateProgram("lineBlendComposite").draw(t,l.TRIANGLES,e.Z.disabled,e._.disabled,d,e.$.disabled,((e,t,i,s)=>({u_image:0,u_opacity:t,u_blend_mode:i,u_max_density:s}))(0,c,ia[s].compositeUniformValue,h),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}function la(t,i,s,r){const{painter:o,sourceCache:n,layer:a,coords:l,colorMode:c,elevationType:h,terrainEnabled:d,pass:u}=t,p=o.context.gl,f=a.paint.get("fill-pattern"),m=a.paint.get("fill-pattern-cross-fade"),_=f.constantOr(null);let g=h;"road"!==h||i&&!d||(g="none");const y="road"===g,v=t.painter.shadowRenderer,b=y&&!!v&&v.enabled,x=new e.Z(o.context.gl.LEQUAL,e.Z.ReadOnly,o.depthRangeFor3D);let w=[0,0,0];if(b){const t=o.style.directionalLight,i=o.style.ambientLight;t&&i&&(w=e.aF(o.style,t,i));}const T=f&&f.constantOr(1),S=o.terrain&&o.terrain.renderingToTexture,C=(t,u)=>{let f,g,C,E,I;u?(f=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",C=p.LINES):(f=T?"fillPattern":"fill",C=p.TRIANGLES);const D=[];for(const P of l){const l=n.getTile(P);if(T&&!l.patternsLoaded())continue;const L=l.getBucket(a);if(!L)continue;const R=i?L.hdExt&&L.hdExt.elevationBufferData:L.bufferData;if(!R||R.isEmpty())continue;o.prepareDrawTile();const A=R.programConfigurations.get(a.id),M=o.isTileAffectedByFog(P),F=[],O=[];y&&(F.push("ELEVATED_ROADS"),O.push(R.elevatedLayoutVertexBuffer)),b&&F.push("RENDER_SHADOWS","NORMAL_OFFSET"),S&&s&&F.push("USE_MRT1"),T&&(o.context.activeTexture.set(p.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),A.updatePaintBuffers());let B=!1;if(_&&l.imageAtlas){const t=l.imageAtlas,i=e.aG.from(_),s=i.getPrimary().scaleSelf(e.e.devicePixelRatio).toString(),r=i.getSecondary(),o=t.patternPositions.get(s),n=r?t.patternPositions.get(r.scaleSelf(e.e.devicePixelRatio).toString()):null;B=!!o&&!!n,o&&A.setConstantPatternPositions(o,n);}m>0&&(B||A.getPatternTransitionVertexBuffer("fill-pattern"))&&F.push("FILL_PATTERN_TRANSITION");const k=o.getOrCreateProgram(f,{config:A,overrideFog:M,defines:F}),z=o.translatePosMatrix(P.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));b&&v.setupShadows(l.tileID.toUnwrapped(),k,"vector-tile");const U=a.paint.get("fill-emissive-strength");if(u){E=R.lineIndexBuffer,I=R.lineSegments;const e=o.terrain&&o.terrain.renderingToTexture?o.terrain.drapeBufferSize:[p.drawingBufferWidth,p.drawingBufferHeight];g="fillOutlinePattern"===f&&T?Ln(z,U,o,l,e,w,m):Pn(z,U,e,w);}else E=R.indexBuffer,I=R.triangleSegments,g=T?Dn(z,U,o,l,w,m):In(z,U,w);o.uploadCommonUniforms(o.context,k,P.toUnwrapped());let N=t;if(("road"===h&&!d||"offset"===h)&&(N=x),!I||I.get&&0===I.get().length)continue;const j=r||o.stencilModeForClipping(P);let V="fallthrough";!u&&Xs.drawFillFrcCoverageFirstPass&&(V=Xs.drawFillFrcCoverageFirstPass({painter:o,layer:a,bucket:L,coord:P,elevatedGeometry:i,program:k,programConfiguration:A,uniformValues:g,drawMode:C,depthMode:N,stencilMode:j,colorMode:c,bufferData:R,indexBuffer:E,segments:I,dynamicBuffers:O,polygonCoverageTiles:D})),"fallthrough"===V&&k.draw(o,C,N,j,c,e.$.disabled,g,a.id,R.layoutVertexBuffer,E,I,a.paint,o.transform.zoom,A,O);}!u&&Xs.drawFillFrcCoverageSecondPass&&Xs.drawFillFrcCoverageSecondPass(o,a,D,C,c);};o.renderPass===u&&C(o.depthModeForSublayer(1,"opaque"===o.renderPass?e.Z.ReadWrite:e.Z.ReadOnly),!1),"none"===g&&"translucent"===o.renderPass&&a.paint.get("fill-antialias")&&C(o.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,e.Z.ReadOnly),!0);}function ca(t){return [t[0]*e.ea,t[1]*e.ea,t[2]*e.ea,0]}function ha(t,i,s,r,o,n,a,l,c,h){const d=o.getSource(),u=r.globeSharedBuffers;if(!u)return;let p,f,m;if(s&&(p=o.getTile(s)),d instanceof nr?(f=d.texture,m=e.du(0,0,r.transform)):p&&s&&(f=p.texture,m=e.du(s.canonical.z,s.canonical.x,r.transform)),!f||!m)return;i||(m=e.aN(e.Y(),m,[1,-1,1]));const _=r.context,g=_.gl,y="nearest"===n.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,v=r.colorModeForDrapableLayerRenderPass(a),b=l.defines;b.push("GLOBE_POLES");const x=new e.Z(g.LEQUAL,e.Z.ReadWrite,r.depthRangeFor3D),w=r.transform.expandedFarZProjMatrix,T=Float32Array.from(e.b4(e.b5(new e.bX(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),_.activeTexture.set(g.TEXTURE0),f.bind(y,g.CLAMP_TO_EDGE),_.activeTexture.set(g.TEXTURE1),f.bind(y,g.CLAMP_TO_EDGE),"useMipmap"in f&&_.extTextureFilterAnisotropic&&r.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const[S,C,E,I]=s?u.getPoleBuffers(s.canonical.z,!1):u.getPoleBuffers(0,!0),D=t;let P;i?(P=S,r.renderDefaultNorthPole=0!==D):(P=C,r.renderDefaultSouthPole=0!==D);const L=ca(l.mix),R=((e,t,i,s,r,o,n,a,l,c,h,d,u,p)=>On(e,t,i,s,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},n,[0,0]||[0,0],l,2,h,d,u,1,0,p))(r,w,T,m,e.S(r.transform.zoom),0,n,0,D,0,L,l.offset,l.range,a),A=r.getOrCreateProgram("raster",{defines:b});r.uploadCommonUniforms(_,A,null),A.draw(r,g.TRIANGLES,x,h,v,c,R,n.id,P,E,I);}function da(e){if(e.isOrthographic)return [0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),s=i-t,r=.2*e.height,o=t+r;return [t,i,(o-r-t)/s,(o-t)/s]}function ua(e,t,i,s){if(e)return "raster-array"===t.type?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:ca(s.mix),offset:s.offset,buffer:0,tileSize:1}}const pa=e.d0(new Float32Array(16)),fa=e.a_([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ma}=fa;function _a(e,t,i,s){e.emplaceBack(t,i,s);}class ga{constructor(t){this.vertexArray=new e.eb,this.indices=new e.ad,_a(this.vertexArray,-1,-1,1),_a(this.vertexArray,1,-1,1),_a(this.vertexArray,-1,1,1),_a(this.vertexArray,1,1,1),_a(this.vertexArray,-1,-1,-1),_a(this.vertexArray,1,-1,-1),_a(this.vertexArray,-1,1,-1),_a(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,ma),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.ac.simpleSegment(0,0,36,12);}}function ya(t,i,s,r,o,n){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,s,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[s.r,s.g,s.b,s.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.ee(e.ef(),r),o,h,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,i.skyboxTexture,0),s.draw(t,a.TRIANGLES,e.Z.disabled,e._.disabled,e.a1.unblended,e.$.frontCW,d,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const va=e.a_([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class ba{constructor(t){const i=new e.eg;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const s=new e.ad;s.emplaceBack(0,1,2),s.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,va.members),this.indexBuffer=t.createIndexBuffer(s),this.segments=e.ac.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const xa=e.a_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class wa{constructor(){this.colorModeAlphaBlendedWriteRGB=new e.a1([e.eh,e.ei,e.eh,e.ei],e.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new e.a1([e.eh,e.ej,e.eh,e.ej],e.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null;}update(t){this._painter=t;const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new ba(i);let t=this.params;const s=t.sizeRange,r=t.intensityRange,o=function(t){const i=e.bi(30),s=[];for(let r=0;r<t;++r){const t=2*Math.PI*i(),r=Math.acos(1-2*i())-.5*Math.PI;s.push(e.bh(Math.cos(r)*Math.cos(t),Math.cos(r)*Math.sin(t),Math.sin(r)));}return s}(t.starsCount),n=e.bi(300),a=new e.ek,l=new e.ad;let c=0;for(let t=0;t<o.length;++t){const i=e.dC([],o[t],200),h=Math.max(0,1+.01*s*(1*n()-.5)),d=Math.max(0,1+.01*r*(1*n()-.5));a.emplaceBack(i[0],i[1],i[2],-1,-1,h,d),a.emplaceBack(i[0],i[1],i[2],1,-1,h,d),a.emplaceBack(i[0],i[1],i[2],1,1,h,d),a.emplaceBack(i[0],i[1],i[2],-1,1,h,d),l.emplaceBack(c+0,c+1,c+2),l.emplaceBack(c+0,c+2,c+3),c+=4;}this.starsVx=i.createVertexBuffer(a,xa.members),this.starsIdx=i.createIndexBuffer(l),this.starsSegments=e.ac.simpleSegment(0,0,a.length,l.length);}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null;}drawAtmosphereGlow(t,i){const s=t.context,r=s.gl,o=t.transform,n=new e.Z(r.LEQUAL,e.Z.ReadOnly,[0,1]),a=e.S(o.zoom),l=t.style.getLut(i.scope),c="none"===i.properties.get("color-use-theme"),h=i.properties.get("color").toNonPremultipliedRenderColor(c?null:l),d="none"===i.properties.get("high-color-use-theme"),u=i.properties.get("high-color").toNonPremultipliedRenderColor(d?null:l),p="none"===i.properties.get("space-color-use-theme"),f=i.properties.get("space-color").toNonPremultipliedRenderColor(p?null:l),m=5e-4,_=e.el(i.properties.get("horizon-blend"),0,1,m,.25),g=e.dt(t,s,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.em(o.globeCenterInViewSpace),b=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),x=Math.acos(b/v),w=i=>{const l="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];i&&l.push("ALPHA_PASS");const c=t.getOrCreateProgram("globeAtmosphere",{defines:l}),d=((e,t,i,s,r,o,n,a,l,c,h,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:s,u_horizon:r,u_transition:o,u_fadeout_range:n,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:h,u_horizon_angle:d}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,_,h,u,f,y,x);t.uploadCommonUniforms(s,c);const p=this.atmosphereBuffer;p&&c.draw(t,r.TRIANGLES,n,e._.disabled,i?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,e.$.backCW,d,i?"atmosphere_glow_alpha":"atmosphere_glow",p.vertexBuffer,p.indexBuffer,p.segments);};w(!1),w(!0);}drawStars(t,i){const s=e.b0(i.properties.get("star-intensity"),0,1);if(0===s)return;const r=t.context,o=r.gl,n=t.transform,a=t.getOrCreateProgram("stars"),l=e.bd([]);e.be(l,l,-n._pitch),e.bf(l,l,-n.angle),e.be(l,l,e.au(n._center.lat)),e.en(l,l,-e.au(n._center.lng));const c=e.bg(new Float32Array(16),l),h=e.X([],n.starsProjMatrix,c),d=e.ee([],c),u=e.eo([],d);let p=this.params.sizeMultiplier;const f=[0,1,0];e.ct(f,f,u),e.dC(f,f,p);const m=[1,0,0];e.ct(m,m,u),e.dC(m,m,p);const _=(g=f,y=m,v=s,{u_matrix:Float32Array.from(h),u_up:g,u_right:y,u_intensity_multiplier:v});var g,y,v;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,e.Z.disabled,e._.disabled,this.colorModeAlphaBlendedWriteRGB,e.$.disabled,_,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}class Ta{}class Sa{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,s){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=s.gl,o=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),n=new ArrayBuffer(o),a=new Int16Array(n);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(n));const l=new e.ep;for(let e=0;e<o/2;e+=3){const t=a[e],i=a[e+1],s=a[e+2];l.emplaceBack(t,i),l.emplaceBack(i,s),l.emplaceBack(s,t);}const c=s.bindVertexArrayOES.current,h=new Ta;return h.buf=new Vn(s,l),h.lastUsedFrameIdx=t,this._storage.set(i.id,h),s.bindVertexArrayOES.set(c),h.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class Ca{constructor(){this.occluderSize=30,this.depthOffset=-1e-4;}}const Ea={symbol:function(t,i,s,r,o){if("translucent"!==t.renderPass)return;const n=e._.disabled,a=t.colorModeForRenderPass(),l=s.layout.get("text-variable-anchor"),c=s.layout.get("text-size-scale-range"),h=e.b0(t.scaleFactor,c[0],c[1]);l&&function(t,i,s,r,o,n,a,l){const c=i.transform,h="map"===o,d="map"===n;for(const i of t){const t=r.getTile(i),o=t.getBucket(s);if(!o||!o.text||!o.text.segments.get().length)continue;const n=e.cG(o.textSizeData,c.zoom,l),u=vt(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=e.dY(u,t.tileID.canonical,d,h,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();n&&Kn(o,h,d,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),n,m);}}(r,t,s,i,s.layout.get("text-rotation-alignment"),s.layout.get("text-pitch-alignment"),o,h);const d=0!==s.paint.get("icon-opacity").constantOr(1),u=0!==s.paint.get("text-opacity").constantOr(1);void 0!==s.layout.get("symbol-sort-key").constantOr(1)&&(d||u)?Yn(t,i,s,r,n,a):(d&&Yn(t,i,s,r,n,a,{onlyIcons:!0}),u&&Yn(t,i,s,r,n,a,{onlyText:!0})),i.map.showCollisionBoxes&&xt.drawCollisionDebug&&(xt.drawCollisionDebug(t,i,s,r,s.paint.get("text-translate"),s.paint.get("text-translate-anchor"),!0),xt.drawCollisionDebug(t,i,s,r,s.paint.get("icon-translate"),s.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,s,r){if("translucent"!==t.renderPass)return;const o=s.paint.get("circle-opacity"),n=s.paint.get("circle-stroke-width"),a=s.paint.get("circle-stroke-opacity"),l=void 0!==s.layout.get("circle-sort-key").constantOr(1),c=s.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,d=h.gl,u=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=s.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,e.Z.ReadOnly),_=new e.Z(t.context.gl.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D),g="none"===f||p?m:_,y=e._.disabled,v=t.colorModeForDrapableLayerRenderPass(c),b="globe"===u.projection.name,x=[e.a7(u.center.lng),e.a8(u.center.lat)],w=[];for(let o=0;o<r.length;o++){const n=r[o],a=i.getTile(n),c=a.getBucket(s);if(!c||c.projection.name!==u.projection.name)continue;const h=c.programConfigurations.get(s.id),d=c.layoutVertexBuffer,p=c.globeExtVertexBuffer,f=c.indexBuffer,m=e.e2(s),_=[p],g=t.isTileAffectedByFog(n);b&&m.push("PROJECTION_GLOBE_VIEW"),m.push("DEPTH_D24"),t.terrain&&u.depthOcclusionForSymbolsAndCircles&&m.push("DEPTH_OCCLUSION"),c.hdExt&&c.hdExt.hasElevation&&!t.terrain&&(m.push("ELEVATED_ROADS"),_.push(c.hdExt.elevatedLayoutVertexBuffer));const y=t.getOrCreateProgram("circle",{config:h,defines:m,overrideFog:g}),v=u.projection.createInversionMatrix(u,n.canonical),T={programConfiguration:h,program:y,layoutVertexBuffer:d,dynamicBuffers:_,indexBuffer:f,uniformValues:e.e3(t,n,a,v,x,s),tile:a};if(l){const t=c.segments.get();for(const i of t)w.push({segments:new e.ac([i]),sortKey:i.sortKey,state:T});}else w.push({segments:c.segments,sortKey:0,state:T});}l&&w.sort((e,t)=>e.sortKey-t.sortKey);const T={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const i of w){const{programConfiguration:r,program:o,layoutVertexBuffer:n,dynamicBuffers:a,indexBuffer:l,uniformValues:c,tile:p}=i.state,f=i.segments;t.terrain&&t.terrain.setupElevationDraw(p,o,T),t.uploadCommonUniforms(h,o,p.tileID.toUnwrapped()),o.draw(t,d.TRIANGLES,g,y,v,e.$.disabled,c,s.id,n,l,f,s.paint,u.zoom,r,a);}},heatmap:function(t,i,s,r){if(0!==s.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,n=o.gl,a=e._.disabled,l=new e.a1([n.ONE,n.ONE,n.ONE,n.ONE],e.C.transparent,[!0,!0,!0,!0]),c="globe"===t.transform.projection.name?.5:.25;s.heatmapFbo=Zn.createWithTexture(o,s.heatmapFbo,t.width*c,t.height*c),o.clear({color:e.C.transparent});const h=t.transform,d="globe"===h.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[],p=d?e.$.frontCCW:e.$.disabled,f=[e.a7(h.center.lng),e.a8(h.center.lat)];for(let c=0;c<r.length;c++){const m=r[c];if(i.hasRenderableParent(m))continue;const _=i.getTile(m),g=_.getBucket(s);if(!g||g.projection.name!==h.projection.name)continue;const y=t.isTileAffectedByFog(m),v=g.programConfigurations.get(s.id),b=t.getOrCreateProgram("heatmap",{config:v,defines:u,overrideFog:y}),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(_,b),t.uploadCommonUniforms(o,b,m.toUnwrapped());const w=h.projection.createInversionMatrix(h,m.canonical);b.draw(t,n.TRIANGLES,e.Z.disabled,a,l,p,Mn(t,m,_,w,f,x,s.paint.get("heatmap-intensity")),s.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,s.paint,t.transform.zoom,v,d?[g.globeExtVertexBuffer]:null);}o.viewport.set([0,0,t.width,t.height]);}else "translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const s=t.context,r=s.gl,o=i.heatmapFbo;if(!o)return;s.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.colorAttachment0.get()),s.activeTexture.set(r.TEXTURE1);let n=i.colorRampTexture;n||(n=i.colorRampTexture=new e.T(s,i.colorRamp,r.RGBA8)),n.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,r.TRIANGLES,e.Z.disabled,e._.disabled,t.colorModeForRenderPass(),e.$.disabled,((e,t)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,s));},line:function(e,t,i,s){const r=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===r.constantOr(1)||0===o.constantOr(1))return;const n=i.paint.get("line-blend-mode"),a=e.terrain&&e.terrain.renderingToTexture;if("default"===n||"globe"===e.transform.projection.name)"translucent"===e.renderPass&&Jn(e,t,i,s);else {if(a)return void function(e,t,i,s,r){if("translucent"!==e.renderPass)return;const o=e.context,n=o.gl,a=e.terrain;if(!a)return;const l=o.bindFramebuffer.current,c="mrt-fallback"===e.emissiveMode,h=a.drapeBufferSize[0],d=a.drapeBufferSize[1];i.lineBlendFbos||(i.lineBlendFbos=new ea),i.lineBlendFbos.drapeFbo=Zn.createWithTexture(o,i.lineBlendFbos.drapeFbo,h,d,!0),c&&n.drawBuffers([n.COLOR_ATTACHMENT0]),o.clear({color:ia[r].clearColor,depth:1,stencil:0});const u=e.currentStencilSource,p=e._tileClippingMaskIDs,f=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1;const m=e._terrain;e._terrain=null,e._renderTileClippingMasks(i,t,s),Jn(e,t,i,s,ra(r,e.context),!0),e._terrain=m,e.currentStencilSource=u,e._tileClippingMaskIDs=p,e.nextStencilID=f,c&&n.drawBuffers([n.COLOR_ATTACHMENT0,n.COLOR_ATTACHMENT1]);const _=a.drapeBufferSize,g=i.lineBlendFbos&&i.lineBlendFbos.drapeFbo;g&&("additive"===r&&na(e,i,g),aa(e,i,r,g,l,_));}(e,t,i,s,n);if("offscreen"===e.renderPass)return void function(e,t,i,s,r){const o=e.context,n=Math.ceil(e.width),a=Math.ceil(e.height);i.lineBlendFbos||(i.lineBlendFbos=new ea),i.lineBlendFbos.fbo=Zn.createWithTexture(o,i.lineBlendFbos.fbo,n,a,!0),o.clear({color:ia[r].clearColor,depth:1,stencil:0});const l=e.currentStencilSource,c=e._tileClippingMaskIDs,h=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1,e._renderTileClippingMasks(i,t,s);const d=e.renderPass;e.renderPass="translucent",Jn(e,t,i,s,ra(r,e.context)),e.renderPass=d,e.currentStencilSource=l,e._tileClippingMaskIDs=c,e.nextStencilID=h,o.viewport.set([0,0,e.width,e.height]),"additive"===r&&na(e,i,i.lineBlendFbos.fbo);}(e,t,i,s,n);if("translucent"===e.renderPass){const t=i.lineBlendFbos&&i.lineBlendFbos.fbo;return void(t&&aa(e,i,n,t,null))}}},fill:function(t,i,s,r){const o=s.paint.get("fill-color"),n=s.paint.get("fill-opacity");if(0===n.constantOr(1))return;const a=s.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=s.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.C.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";let d="none";"none"!==s.layout.get("fill-elevation-reference")?d="road":0!==s.paint.get("fill-z-offset").constantOr(1)&&(d="offset");const u=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:s,coords:r,colorMode:l,elevationType:d,terrainEnabled:u,pass:h};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===d&&!u&&Xs.drawElevatedFillShadows&&Xs.drawElevatedFillShadows(p));const f="mrt-fallback"===t.emissiveMode;if("offset"!==d){if(la(p,!1,f),"road"===d){const o=!u&&"translucent"===t.renderPass;o&&Xs.drawDepthPrepass&&Xs.drawDepthPrepass(t,i,s,r,"geometry"),la(p,!0,f,e._.disabled),o&&Xs.drawElevatedStructures&&Xs.drawElevatedStructures(p);}}else la(p,!1,f,t.stencilModeFor3D());},"fill-extrusion":function(t,i,s,r){const o=s.paint.get("fill-extrusion-opacity"),n=t.context,a=n.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const h="mrt-fallback"===t.emissiveMode,d=t.conflationActive&&t.style.isLayerClipped(s,i.getSource()),u=t.style.order.indexOf(s.fqid);if(d&&function(e,t,i,s,r){for(const o of s){const s=t.getTile(o).getBucket(i);s&&(s.updateReplacement(o,e.replacementSource,r),s.uploadCentroid(e.context));}}(t,i,s,r,u),l||d)for(const e of r){const r=i.getTile(e).getBucket(s);r&&fi(t.context,i,e,r,s,l,d);}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&o<.65&&s._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.aj)return;const n=t.shadowRenderer.getShadowPassDepthMode();di(t,i,s,r,n,e._.disabled,e.a1.disabled,d);}else if("translucent"===t.renderPass){const u=!s.paint.get("fill-extrusion-pattern").constantOr(1),p=s.paint.get("fill-extrusion-color").constantOr(e.C.white);if(!c&&0!==p.a){const n=new e.Z(t.context.gl.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D);1===o&&u?di(t,i,s,r,n,e._.disabled,e.a1.unblended,d):(di(t,i,s,r,n,e._.disabled,e.a1.disabled,d),di(t,i,s,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),d),t.resetStencilClippingMasks());}const f=t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c);if(f&&!ci.drawGroundEffect&&hi(),f&&ci.drawGroundEffect){const o=s.paint.get("fill-extrusion-opacity"),u=s.paint.get("fill-extrusion-ambient-occlusion-intensity"),p=s.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=s.paint.get("fill-extrusion-flood-light-intensity"),m="none"===s.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),_=s.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(m?null:s.lut).toArray01().slice(0,3),g=u>0&&p>0,y=f>0,v=new ui;v.translate=s.paint.get("fill-extrusion-translate"),v.translateAnchor=s.paint.get("fill-extrusion-translate-anchor"),v.edgeRadius=s.layout.get("fill-extrusion-edge-radius"),v.cutoffFadeRange=s.paint.get("fill-extrusion-cutoff-fade-range");const b=n=>{const l=t.depthModeForSublayer(1,e.Z.ReadOnly,a.LEQUAL,!0),c=s.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),h=e.al(.1,3,c),m=t._showOverdrawInspector;if(!m){const c=new e._({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new e.a1([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);ci.drawGroundEffect(v,t,i,s,r,l,c,m,e.$.disabled,n,"sdf",o,u,p,f,_,h,d,!1);}{const c=m?e._.disabled:new e._({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=m?t.colorModeForRenderPass():new e.a1([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.C.transparent,[!0,!0,!0,!0]);ci.drawGroundEffect(v,t,i,s,r,l,c,g,e.$.disabled,n,"color",o,u,p,f,_,h,d,!1);}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let s=l.framebufferCopyTexture;return s&&(!s||s.size[0]===t&&s.size[1]===i)||(s&&s.destroy(),s=l.framebufferCopyTexture=new e.T(n,new e.b({width:t,height:i}),a.RGBA8)),s.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),s},m=(n,l,m)=>{const g=t.depthModeForSublayer(1,e.Z.ReadOnly,a.LEQUAL,!1),y=s.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),b=e.al(.1,3,y);{const c=new e.a1([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0]);ci.drawGroundEffect(v,t,i,s,r,g,e._.disabled,c,e.$.disabled,n,"clear",o,u,p,f,_,b,d,l);}{const c=new e._({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),h=new e.a1([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);ci.drawGroundEffect(v,t,i,s,r,g,c,h,e.$.disabled,n,"sdf",o,u,p,f,_,b,d,l);}h&&!n&&(m=c());{const c=n?a.ZERO:a.ONE_MINUS_DST_ALPHA,h=new e._({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),m=new e.a1([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.C.transparent,[!0,!0,!0,!0]);ci.drawGroundEffect(v,t,i,s,r,g,h,m,e.$.disabled,n,"color",o,u,p,f,_,b,d,l);}if(!h||n){const c=new e.a1([a.ONE,a.ONE,a.ONE,n?a.ZERO:a.ONE],e.C.transparent,[!1,!1,!1,!0],n?a.FUNC_ADD:a.MAX);ci.drawGroundEffect(v,t,i,s,r,g,e._.disabled,c,e.$.disabled,n,"clear",o,u,p,f,_,b,d,l,m);}else {a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new e._({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),h=new e.a1([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!0,!1,!1,!1],a.MAX);ci.drawGroundEffect(v,t,i,s,r,g,c,h,e.$.disabled,n,"emissive",o,u,p,f,_,b,d,l,m),a.drawBuffers([a.COLOR_ATTACHMENT0]);}};if(g||y){let e;t.prepareDrawTile(),h&&!g||(e=c()),g&&m(!0,!1,e),y&&m(!1,!0,e);}}else g&&b(!0),y&&b(!1),(g||y)&&t.resetStencilClippingMasks();}}},hillshade:function(t,i,s,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;if(t.style.disableElevatedTerrain)return;const o=t.context,n=t.terrain&&t.terrain.renderingToTexture,[a,l]="translucent"!==t.renderPass||n?[{},r]:t.stencilConfigForOverlap(r);for(const r of l){const o=i.getTile(r);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)Io(t,o,s);else if("translucent"===t.renderPass){const i=t.depthModeForSublayer(0,e.Z.ReadOnly),l=s.paint.get("hillshade-emissive-strength"),c=t.colorModeForDrapableLayerRenderPass(l),h=n&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):a[r.overscaledZ];Co(t,r,o,s,i,h,c);}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks();},raster:function(t,i,s,r,o,n){if("translucent"!==t.renderPass)return;const a=s.paint.get("raster-opacity");if(0===a)return;const l=s.paint.get("raster-allow-draping"),c="globe"===t.transform.projection.name;let h=s.paint.get("raster-elevation"),d="ground"===s.paint.get("raster-elevation-reference");l||0!==h||(h=.001,d=!0);const u=h>0,p=t.terrain&&t.terrain.exaggeration()>0&&u&&d,f=u&&c,m=!c&&p;if(t.renderElevatedRasterBackface&&!f)return;const _=t.context,g=_.gl,y=i.getSource(),v=function(t,i,s,r,o){const n=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),h=i.paint.get("raster-color-mix");let d=i.paint.get("raster-color-range");const u=[h[0],h[1],h[2],0],p=h[3];let f="nearest"===c?r.NEAREST:r.LINEAR;if(a&&(l.push("RASTER_ARRAY"),n||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),f=r.NEAREST,n&&"log"===i.paint.get("raster-color-scale")&&l.push("RASTER_COLOR_SCALE_LOG"),!d&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(d=e.fields.range);}if(d=d||[0,1],n){l.push("RASTER_COLOR"),s.activeTexture.set(r.TEXTURE2),i.updateColorRamp(d);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(s,i.colorRamp,r.RGBA8)),t.bind(f,r.CLAMP_TO_EDGE);}return o&&l.push("USE_MRT1"),{mix:u,range:d,offset:p,defines:l,resampling:f}}(y,s,_,g,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(y instanceof nr&&!r.length&&!c)return;const b=s.paint.get("raster-emissive-strength"),x=t.colorModeForDrapableLayerRenderPass(b),w=t.terrain&&t.terrain.renderingToTexture,T=!t.options.moving,S="nearest"===s.paint.get("raster-resampling")?g.NEAREST:g.LINEAR;if(y instanceof nr&&!r.length&&(y.onNorthPole||y.onSouthPole)){const r=u?t.stencilModeFor3D():e._.disabled;return void ha(h,!!y.onNorthPole,null,t,i,s,b,v,e.$.disabled,r)}if(!r.length)return;const[C,E]=y instanceof nr||w?[{},r]:t.stencilConfigForOverlap(r),I=E.at(-1).overscaledZ;f&&v.defines.push("PROJECTION_GLOBE_VIEW"),u&&v.defines.push("RENDER_CUTOFF","ELEVATED"),p&&v.defines.push("ELEVATION_REFERENCE_GROUND");const D=(r,o,l)=>{for(const d of r){const r=d.toUnwrapped(),E=i.getTile(d);if(w&&(!E||!E.hasData()))continue;_.activeTexture.set(g.TEXTURE0);const D=ua(E,y,s,v);if(!D||!D.texture)continue;const{texture:P,mix:L,offset:R,tileSize:A,buffer:M}=D;let F,O;w?(F=e.Z.disabled,O=d.projMatrix):u?(F=new e.Z(g.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D),O=c?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(r,T)):(F=t.depthModeForSublayer(d.overscaledZ-I,1===a?e.Z.ReadWrite:e.Z.ReadOnly,g.LESS),O=t.transform.calculateProjMatrix(r,T));const B=t.terrain&&w?t.terrain.stencilModeForRTTOverlap(d):C[d.overscaledZ],k=n?0:s.paint.get("raster-fade-duration");E.registerFadeDuration(k);const z=i.findLoadedParent(d,0),U=Ai(E,z,i,t.transform,k);let N,j;!U.isFading&&E.refreshedUponExpiration&&(E.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),_.activeTexture.set(g.TEXTURE0),P.bind(S,g.CLAMP_TO_EDGE),_.activeTexture.set(g.TEXTURE1),z?(z.texture&&z.texture.bind(S,g.CLAMP_TO_EDGE),N=Math.pow(2,z.tileID.overscaledZ-E.tileID.overscaledZ),j=[E.tileID.canonical.x*N%1,E.tileID.canonical.y*N%1]):P.bind(S,g.CLAMP_TO_EDGE),"useMipmap"in P&&_.extTextureFilterAnisotropic&&t.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const V=t.transform;let G;const q=u?da(V):[0,0,0,0];let Z,$,H,W,X,K=0;if(f&&y instanceof nr&&y.coordinates.length>3)Z=Float32Array.from(e.b4(e.b5(new e.bX(0,0,0)))),$=Float32Array.from(V.globeMatrix),H=Float32Array.from(e.b6(V)),W=[e.a7(V.center.lng),e.a8(V.center.lat)],G=y.elevatedGlobePerspectiveTransform,X=y.elevatedGlobeGridMatrix||new Float32Array(9);else if(f){const t=e.b2(d.canonical);K=e.b3(t.getCenter().lat),Z=Float32Array.from(e.b4(e.b5(d.canonical))),$=Float32Array.from(V.globeMatrix),H=Float32Array.from(e.b6(V)),W=[e.a7(V.center.lng),e.a8(V.center.lat)],G=[0,0],X=Float32Array.from(e.b7(d.canonical,t,K,V.worldSize/V._pixelsPerMercatorPixel));}else G=y instanceof nr?y.perspectiveTransform:[0,0],Z=new Float32Array(16),$=new Float32Array(9),H=new Float32Array(16),W=[0,0],X=new Float32Array(9);const Y=On(t,O,Z,$,H,X,j||[0,0],e.S(t.transform.zoom),W,q,N||1,U,s,G,h,2,L,R,v.range,A,M,b),Q=t.isTileAffectedByFog(d),J=t.getOrCreateProgram("raster",{defines:v.defines,overrideFog:Q});if(t.uploadCommonUniforms(_,J,r),y instanceof nr){const i=y.elevatedGlobeVertexBuffer,r=y.elevatedGlobeIndexBuffer;if(w||!c)y.boundsBuffer&&y.boundsSegments&&J.draw(t,g.TRIANGLES,F,e._.disabled,x,e.$.disabled,Y,s.id,y.boundsBuffer,t.quadTriangleIndexBuffer,y.boundsSegments);else if(i&&r){const n=V.zoom<=e.e9?y.elevatedGlobeSegments:y.getSegmentsForLongitude(V.center.lng);n&&J.draw(t,g.TRIANGLES,F,e._.disabled,x,o,Y,s.id,i,r,n);}}else if(f){F=new e.Z(g.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D);const i=t.globeSharedBuffers;if(i){p&&(t.terrain.setupElevationDraw(E,J),t.uploadCommonUniforms(_,J,E.tileID.toUnwrapped()));const[e,r,n]=i.getGridBuffers(K,!1),a=J.getAttributeLocation(g,"a_texture_pos");-1!==a&&g.vertexAttribI4ui(a,0,0,0,0),J.draw(t,g.TRIANGLES,F,l||B,t.colorModeForRenderPass(),o,Y,s.id,e,r,n);}}else if(m)F=new e.Z(g.LEQUAL,e.Z.ReadOnly,t.depthRangeFor3D),t.terrain.setupElevationDraw(E,J),t.uploadCommonUniforms(_,J,E.tileID.toUnwrapped()),V.pitch>20&&J.draw(t,g.TRIANGLES,F,e._.disabled,e.a1.disabled,e.$.frontCCW,Y,s.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),J.draw(t,g.TRIANGLES,F,B,x,e.$.backCCW,Y,s.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else {const{tileBoundsBuffer:i,tileBoundsIndexBuffer:r,tileBoundsSegments:o}=t.getTileBoundsBuffers(E);J.draw(t,g.TRIANGLES,F,B,x,e.$.disabled,Y,s.id,i,r,o);}}if(!(y instanceof nr)&&f)for(const n of r){const r=n.canonical.y===(1<<n.canonical.z)-1;0===n.canonical.y&&ha(h,!0,n,t,i,s,b,v,o,l||e._.disabled),r&&ha(h,!1,n,t,i,s,b,v,o===e.$.frontCW?e.$.backCW:e.$.frontCW,l||e._.disabled);}};f?D(E,t.renderElevatedRasterBackface?e.$.backCW:e.$.frontCW,t.stencilModeFor3D()):D(E,e.$.disabled,void 0),t.resetStencilClippingMasks();},background:function(t,i,s,r){const o=s.paint.get("background-color"),n="none"===s.paint.get("background-color-use-theme").constantOr("default"),a=s.paint.get("background-opacity"),l=s.paint.get("background-emissive-strength"),c="viewport"===s.paint.get("background-pitch-alignment");if(0===a)return;const h=t.context,d=h.gl,u=t.transform,p=u.tileSize,f=s.paint.get("background-pattern");let m;if(void 0!==f){if(null===f)return;if(m=t.imageManager.getPattern(e.I.from(f.toString()),s.scope,t.style.getLut(s.scope)),!m)return}const _=!f&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==_)return;const g=e._.disabled,y=t.depthModeForSublayer(0,"opaque"===_?e.Z.ReadWrite:e.Z.ReadOnly),v=t.colorModeForDrapableLayerRenderPass(l),b=f?"backgroundPattern":"background";let x,w=r;w||(x=t.getBackgroundTiles(),w=Object.values(x).map(e=>e.tileID)),f&&(h.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,s.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(b,{overrideFog:!1,overrideRtt:!0,defines:T}),r=pa,h=new e.bP(0,0,0,0,0),u=f?Nn(r,l,a,t,f,s.scope,m,c,{tileID:h,tileSize:p}):Un(r,l,a,o.toPremultipliedRenderColor(n?null:s.lut));return void i.draw(t,d.TRIANGLES,y,g,v,e.$.disabled,u,s.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const _ of w){const w=t.isTileAffectedByFog(_),S=t.getOrCreateProgram(b,{overrideFog:w,defines:T}),C=_.toUnwrapped(),E=r?_.projMatrix:t.transform.calculateProjMatrix(C);t.prepareDrawTile();const I=i?i.getTile(_):x?x[_.key]:new fs(_,p,u.zoom,t),D=f?Nn(E,l,a,t,f,s.scope,m,c,{tileID:_,tileSize:p}):Un(E,l,a,o.toPremultipliedRenderColor(n?null:s.lut));t.uploadCommonUniforms(h,S,C);const{tileBoundsBuffer:P,tileBoundsIndexBuffer:L,tileBoundsSegments:R}=t.getTileBoundsBuffers(I);S.draw(t,d.TRIANGLES,y,g,v,e.$.disabled,D,s.id,P,L,R);}},sky:function(t,i,s){const r=t._atmosphere?e.S(t.transform.zoom):1,o=s.paint.get("sky-opacity")*r;if(0===o)return;const n=t.context,a=s.paint.get("sky-type"),l=new e.Z(n.gl.LEQUAL,e.Z.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?s.needsSkyboxCapture(t)&&(function(t,i){const s=t.context,r=s.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=s.createFramebuffer(32,32,1,null),i.skyboxGeometry=new ga(s),i.skyboxTexture=s.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null);}s.bindFramebuffer.set(o.framebuffer),s.viewport.set([0,0,32,32]);const n=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.ec(l,.5*-Math.PI),ya(t,i,a,l,n,0),e.ec(l,.5*Math.PI),ya(t,i,a,l,n,1),e.ed(l,.5*-Math.PI),ya(t,i,a,l,n,2),e.ed(l,.5*Math.PI),ya(t,i,a,l,n,3),e.d0(l),ya(t,i,a,l,n,4),e.ec(l,Math.PI),ya(t,i,a,l,n,5),s.viewport.set([0,0,t.width,t.height]);}(t,s),s.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,i,s,r,o){const n=t.context,a=n.gl,l=t.transform,c=t.getOrCreateProgram("skybox");n.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const h=((e,t,i,s,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:s,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),0,r,o);t.uploadCommonUniforms(n,c),c.draw(t,a.TRIANGLES,s,e._.disabled,t.colorModeForRenderPass(),e.$.backCW,h,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,s,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,s,r,o){const n=t.context,a=n.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new ga(n)),n.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(n,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=((t,i,s,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.au(s),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.uploadCommonUniforms(n,c),c.draw(t,a.TRIANGLES,s,e._.disabled,t.colorModeForRenderPass(),e.$.backCW,d,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,s,l,o,c);},custom:function(t,i,s,r){const o=t.context,n=s.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&s.isDraped(i)){if("offscreen"===t.renderPass){const i=n.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const s=t.transform.pointMerc;i.call(n,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.S(t.transform.zoom),[s.x,s.y],t.transform.pixelsPerMeterRatio);}else i.call(n,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const i=n.renderToTile;if(i){const s=r[0].canonical,a={x:s.x+r[0].wrap*(n.wrapTileId?0:1<<s.z),y:s.y,z:s.z};o.setDepthMode(e.Z.disabled),o.setStencilMode(e._.disabled),o.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults();const l=o.gl;"mrt-fallback"===t.emissiveMode&&l.drawBuffers([l.COLOR_ATTACHMENT0]),i.call(n,o.gl,a),"mrt-fallback"===t.emissiveMode&&l.drawBuffers([l.COLOR_ATTACHMENT0,l.COLOR_ATTACHMENT1]),o.setDirty(),t.setBaseState();}return}t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(e._.disabled);const i="3d"===n.renderingMode?new e.Z(t.context.gl.LEQUAL,e.Z.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,e.Z.ReadOnly);if(o.setDepthMode(i),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;n.render(o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.S(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio);}else n.render(o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null);}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.");}},Ia={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const s of i){const i=t.getTile(s).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0;},raster:function(e,t,i){const s=t.getSource();if("raster-array"!==s.type||!s.loaded())return;const r=e.sourceLayer||s.rasterLayerIds&&s.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-array-band")||s.getInitialBand(r);if(null==o)return;const n=t.getIds().map(e=>t.getTileByID(e));for(const t of n)t.updateNeeded(e.id,o)&&s.prepareTile(t,r,e.id,o);}};async function Da(e){if(await hi(),Object.assign(Ea,{model:ci.drawModels}),Object.assign(Ia,{model:ci.prepare}),e&&!e._destroyed&&!e._shadowRenderer){const t=ci.ShadowRenderer;t&&(e._shadowRenderer=new t(e));}}class Pa{constructor(t,i,s,r,o){this.context=new $n(t,i),this.transform=s,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.elevationCoverageSnapshot=null,this.elevationProvidersReady=void 0,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=Xs.FrcCoverageRenderer?new Xs.FrcCoverageRenderer:null,this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParamsOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:-1,lodSwitchFadeDuration:.5},this.occlusionParams=new Ca,this.setup(),this.numSublayers=gs.maxUnderzooming+gs.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this.frameTimeDelta=0,this.lastPaintStartTimeStamp=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eq,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._wireframeDebugCache=new Sa,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const n=new e.b({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,n,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.maxFrontCutoffRawStart=0,this.worldview=o,this._forceEmissiveMode=!1,this.emissiveMode="constant";}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new wn(this,e));const s=this._terrain;this.transform.elevation=i?s:null,s.update(e,this.transform,t),this.transform.elevation&&!s.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,s]=t.getRangeForProjection();if(i>s)return void(this.transform.fogCullDistSq=null);const r=i+.78*(s-i);this.transform.fogCullDistSq=r*r;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new wn(this,this.style)),this._forceTerrainMode=e;}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.e.devicePixelRatio,this.height=i*e.e.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const t=this.context,i=new e.bC;i.emplaceBack(0,0),i.emplaceBack(e.a2,0),i.emplaceBack(0,e.a2),i.emplaceBack(e.a2,e.a2),this.tileExtentBuffer=t.createVertexBuffer(i,e.bE.members),this.tileExtentSegments=e.ac.simpleSegment(0,0,4,2);const s=new e.bC;s.emplaceBack(0,0),s.emplaceBack(e.a2,0),s.emplaceBack(0,e.a2),s.emplaceBack(e.a2,e.a2),this.debugBuffer=t.createVertexBuffer(s,e.bE.members),this.debugSegments=e.ac.simpleSegment(0,0,4,5);const r=new e.bC;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.bE.members),this.viewportSegments=e.ac.simpleSegment(0,0,4,2);const o=new e.bs;o.emplaceBack(0,0,0,0),o.emplaceBack(e.a2,0,e.a2,0),o.emplaceBack(0,e.a2,0,e.a2),o.emplaceBack(e.a2,e.a2,e.a2,e.a2),this.mercatorBoundsBuffer=t.createVertexBuffer(o,hs.members),this.mercatorBoundsSegments=e.ac.simpleSegment(0,0,4,2);const n=new e.ad;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(n);const a=new e.bD;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.b({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.Y();const l=this.context.gl;this.stencilClearMode=new e._({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,e.Z.disabled,this.stencilClearMode,e.a1.disabled,e.$.disabled,Us(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(t,i,s){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!s||0===s.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of s)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const r=this.context,o=r.gl;this.nextStencilID+s.length>256&&this.clearStencil(),r.setColorMode(e.a1.disabled),r.setDepthMode(e.Z.disabled);const n=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of s){const s=i.getTile(t),r=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(s);n.draw(this,o.TRIANGLES,e.Z.disabled,new e._({func:o.ALWAYS,mask:0},r,255,o.KEEP,o.KEEP,o.REPLACE),e.a1.disabled,e.$.disabled,Us(t.projMatrix),"$clipping",a,l,c);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e._({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e._({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,s=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=s.at(-1).overscaledZ,o=s[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let s=0;s<o;s++)t[s+r]=new e._({func:i.GEQUAL,mask:255},s+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[t,s]}return [{[r]:e._.disabled},s]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new e.a1([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.C(i,i,i,0),[!0,!0,!0,!0])}return "opaque"===this.renderPass?e.a1.unblended:e.a1.alphaBlended}colorModeForDrapableLayerRenderPass(t){const i=this.context.gl;return (()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new e.a1([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.C(0,0,0,t??0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new e.a1([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(t,i,s,r=!1){if(this.depthOcclusion)return new e.Z(this.context.gl.GREATER,e.Z.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!r)return e.Z.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.Z(s||this.context.gl.LEQUAL,i,[o,o])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,i=Math.ceil(this.width),s=Math.ceil(this.height),r=this.context.bindFramebuffer.get(),o=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===s||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==s&&(this.depthFBO=new Zn(this.context,i,s,0,"texture"),this.depthTexture=new e.T(this.context,{width:i,height:s,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(r),t.bindTexture(t.TEXTURE_2D,o),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,s,0,0,i,s,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current));}render(t,i){this.context.sweepPendingPrograms(),this.frameTimeDelta=0===this.lastPaintStartTimeStamp?0:i.paintStartTimeStamp-this.lastPaintStartTimeStamp,this.lastPaintStartTimeStamp=i.paintStartTimeStamp,this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=i,this.frcCoverageSnapshot&&!this.frcCoverageSnapshot.empty()&&(!this.frcCoverageRenderer&&Xs.FrcCoverageRenderer&&(this.frcCoverageRenderer=new Xs.FrcCoverageRenderer),this.frcCoverageRenderer&&this.frcCoverageRenderer.update(this.context,this.frcCoverageSnapshot.tiles));const s=this.style._mergedLayers,r=!(!this.terrain||!this.terrain.enabled),o=()=>this.style._getOrder(r);let n=o(),a=!1,l=!1,c=null,h=0,d=!1;for(const e of n){const t=s[e];"none"!==t.visibility&&("circle"===t.type?a=!0:"building"===t.type?(c=t,++h):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?l=!0:a=!0));}this.updateEmissiveMode();let u=n.map(e=>s[e]);const p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.e.now()),this.imageManager.beginFrame();for(const e in p){const t=p[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++h);}let f=!1;for(const e of u)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const m={},_={},g={},y={},v={};for(const e in p){const t=p[e];m[e]=t.getVisibleCoordinates(),_[e]=m[e].slice().reverse(),g[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(m[e]);}const b=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||f||this._clippingActiveLastFrame){const t=[],i=[];let s=0;for(const e of u)this.isSourceForClippingOrConflation(e,b(e))&&(t.push(e),i.push(s)),s++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const s=[];for(let r=0;r<t.length;r++){const o=t[r],n=i[r],a=this.style.getLayerSourceCache(o);if(!a||!a.used||!a.getSource().usedInConflation&&"clip"!==o.type&&"building"!==o.type)continue;let l=e.er,c=e.cI.None;const h=[];let d=!0;if("building"===o.type)l=e.ev;else if("clip"===o.type)if(l=n,o.isHidden(this.transform.zoom))d=!1;else {if(!o.layout){d=!1;continue}for(const t of o.layout.get("clip-layer-types"))c|="model"===t?e.cI.Model:"symbol"===t?e.cI.Symbol:e.cI.FillExtrusion;for(const t of o.layout.get("clip-layer-scope"))h.push(e.m(t,o.scope));f=!0;}d&&s.push({layer:o.fqid,cache:a,order:l,clipMask:c,clipScope:h});}this.replacementSource.setSources(s),d=!0;}}this._clippingActiveLastFrame=f,d||this.replacementSource.clear(),this.conflationActive=d,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<u.length;e++){const t=u[e];if("none"===t.visibility)continue;const i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=b(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D(r)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const x=this.style&&this.style.fog;x?(this._fogVisible=0!==x.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=x.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(g),this.opaquePassCutoff=0,n=o(),u=n.map(e=>s[e])),this.style.enable3dLights()&&!this._shadowRenderer&&Da(this);const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in p)for(const t of m[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.es(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new wa),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let T=!(!this.style||!this.style.snow),S=!(!this.style||!this.style.rain);if(T&&!this._snow&&Xs.Snow&&(this._snow=new Xs.Snow),!T&&this._snow&&(this._snow.destroy(),delete this._snow),S&&!this._rain&&Xs.Rain&&(this._rain=new Xs.Rain),!S&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),c&&(!this.buildingTileBorderManager&&Xs.BuildingTileBorderManager&&(this.buildingTileBorderManager=new Xs.BuildingTileBorderManager),this.buildingTileBorderManager)){const e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c);}if(!e.et(this.context.gl))return;this.renderPass="offscreen";for(const e of u){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const s=i?_[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||s&&s.length)&&this.renderLayer(this,i,e,s);}this.depthRangeFor3D=[0,1-(u.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const C="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),E=(()=>{if(i.showOverdrawInspector)return e.C.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const s="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(s?null:i).toArray01();return new e.C(...r)}if(C){const s="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(s?null:i).toArray01();return new e.C(...r)}}return e.C.transparent})();if(this.context.clear({color:E,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const s=i?(e.is3D(r)?v:_)[i.id]:void 0;this._renderTileClippingMasks(e,i,s),this.renderLayer(this,i,e,s);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.S(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?_[i.id]:void 0);}function I(e,t){let i;return t&&(i=("symbol"===e.type?g:e.is3D(r)?v:_)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<n.length;){const e=u[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,I(e,i));}++this.currentLayer;}this.renderElevatedRasterBackface=!1;}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const D=w?w.getGroundShadowLayerIndex():-1;let P=!1,L=-1;for(let e=0;e<n.length;++e){const t=u[e];t.isHidden(this.transform.zoom)||t.is3D(r)&&(L=e);}l&&-1===L&&(a=!0);let R=!1;for(;this.currentLayer<n.length;){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer);}else {if(!R&&e.is3D(r)&&!r){const e=this.currentLayer,t=e=>{for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const t=u[this.currentLayer];if("fill"===t.type&&Xs.drawDepthPrepass){const i=this.style.getLayerSourceCache(t);Xs.drawDepthPrepass(this,i,t,I(t,i),e);}}};t("initialize"),t("reset"),this.currentLayer=e,R=!0;}if(a&&!P&&this.terrain&&!this.transform.isOrthographic&&(P=!0,this.blitDepth()),l&&-1!==L&&this.currentLayer===L+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(e,i,i?m[i.id]:void 0),this.renderLayer(this,i,e,I(e,i)),!this.terrain&&w&&this.currentLayer===D){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const e=u[this.currentLayer];if("fill"===e.type&&Xs.drawGroundShadowMask){const t=this.style.getLayerSourceCache(e);Xs.drawGroundShadowMask(this,t,e,I(e,t));}}this.currentLayer=e;}if(w.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=u[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?_[i.id]:void 0);}this.currentLayer=e,this.renderPass="translucent";}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=u[this.currentLayer],s=t.getLayerSourceCache(i),r=s?_[s.id]:void 0;this.terrain||this._renderTileClippingMasks(i,s,s?m[s.id]:void 0),this.renderLayer(this,s,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;u.forEach(e=>{const s=t.getLayerSourceCache(e);s&&!e.isHidden(this.transform.zoom)&&s.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<s.getSource().maxzoom)&&(i=s);}),i&&this.options.showTileBoundaries&&xt.drawDebug&&xt.drawDebug(this,i,i.getVisibleCoordinates(),e.C.red,!1,this.options.showParseStatus);}this.options.showPadding&&xt.drawDebugPadding&&xt.drawDebugPadding(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),d||(this.conflationActive=!1);}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(Ia[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);Ia[e.type](e,t,this);}this.gpuTimingEnd();}renderLayer(e,t,i,s){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||s&&s.length)&&(this.id=i.id,this.gpuTimingStart(i),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(i.type)||e.terrain&&"custom"===i.type)&&"clip"!==i.type&&"slot"!==i.type&&Ea[i.type]&&Ea[i.type](e,t,i,s,this.style.placement.variableOffsets,this.options.isInitialLoad),Ea[i.type]||(i.mayUse("HD")&&async function(){await Ks(),Object.assign(Ea,{building:Xs.drawBuilding,"raster-particle":Xs.drawRasterParticle}),Object.assign(Ia,{"raster-particle":Xs.prepareRasterParticle});}(),i.mayUse("Standard")&&Da(e)),this.gpuTimingEnd());}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let s=this.gpuTimers[e.id];s||(s=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),s.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,s.query);}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i);}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const s=e[i],r=this.context.extTimerQuery,o=r.getQueryParameter(s.query,this.context.gl.QUERY_RESULT)/1e6;r.deleteQueryEXT(s.query),t[i]=o;}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const s of e)i+=t.getQueryParameter(s,t.QUERY_RESULT)/1e6,t.deleteQuery(s);return i}translatePosMatrix(t,i,s,r,o){if(!s[0]&&!s[1])return t;const n=o?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(n){const e=Math.sin(n),t=Math.cos(n);s=[s[0]*t-s[1]*e,s[0]*e+s[1]*t];}const a=[o?s[0]:e.c5(i,s[0],this.transform.zoom),o?s[1]:e.c5(i,s[1],this.transform.zoom),0],l=new Float32Array(16);return e.bM(l,t,a),l}saveTileTexture(e){if(e.context!==this.context)return;const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e];}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}terrainRenderModeElevated(){return this.style&&this.style.hasTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i,s,r){const o=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=void 0===s?this.terrainRenderModeElevated():s,a=void 0===r?"globe"===this.transform.projection.name:r,l=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(l.push("LIGHTING_3D_MODE"),l.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):o||l.push("LIGHTING_3D_MODE")),n&&(l.push("TERRAIN"),this.linearFloatFilteringSupported()&&l.push("TERRAIN_DEM_FLOAT_FORMAT")),a&&l.push("GLOBE"),!this._fogVisible||o||void 0!==t&&!t||l.push("FOG"),o&&l.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&l.push("OVERDRAW_INSPECTOR"),l}getOrCreateProgram(e,t){this.cache=this.cache||{};const{defines:i,config:s,overrideFog:r,overrideRtt:o,overrideTerrain:n,overrideGlobe:a,precompiled:l}=t||{},c=this.currentGlobalDefines(e,r,o,n,a).concat(i||[]),h=this.getShaderSource(e),d=Xs.programUniforms,u=ci.programUniforms,p=jn[e]||d&&d[e]||u&&u[e],f=En.cacheKey(h,e,c,s);return this.cache[f]||(this.cache[f]=new En(this.context,e,h,s,p,c,l)),this.cache[f]}getShaderSource(t){const i=Xs.shaders,s=ci.shaders;return e.eu[t]||i&&i[t]||s&&s[t]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.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 e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy(),this._destroyed=!0;}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i,s){if(this.style.enable3dLights()){const r=this.style.directionalLight,o=this.style.ambientLight;if(r&&o){const n=((t,i,s,r)=>{const o=t.properties.get("direction"),n="none"===t.properties.get("color-use-theme"),a=t.properties.get("color").toNonPremultipliedRenderColor(n?null:s.getLut(t.scope)).toArray01();let l=t.properties.get("intensity");const c="none"===i.properties.get("color-use-theme"),h=i.properties.get("color").toNonPremultipliedRenderColor(c?null:s.getLut(i.scope)).toArray01();let d=i.properties.get("intensity");const u=[o.x,o.y,o.z];r&&(void 0!==r.ambientIntensity&&(d=r.ambientIntensity),void 0!==r.directionalIntensity&&(l=r.directionalIntensity),void 0!==r.ambientColor&&(h[0]=r.ambientColor[0],h[1]=r.ambientColor[1],h[2]=r.ambientColor[2]),void 0!==r.directionalColor&&(a[0]=r.directionalColor[0],a[1]=r.directionalColor[1],a[2]=r.directionalColor[2]));const p=e.dB(h,d),f=e.dB(a,l);return {u_lighting_ambient_color:p,u_lighting_directional_dir:u,u_lighting_directional_color:f,u_ground_radiance:Tn(u,f,p)}})(r,o,this.style,s);i.setLightsUniformValues(t,n);}}}uploadCommonUniforms(t,i,s,r,o,n){if(this.uploadCommonLightUniforms(t,i,n),this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const o=a.getOpacity(this.transform.pitch),n=((t,i,s,r,o,n,a,l,c,h,d,u)=>{const p=t.transform,f="none"===i.properties.get("color-use-theme"),m=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();m[3]=r;const _=t.frameCounter/1e3%1,[g,y]=i.properties.get("vertical-range");return {u_fog_matrix:s?p.calculateFogTileMatrix(s):u||t.identityMat,u_fog_range:i.getRangeForProjection(),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,y),y],u_fog_temporal_offset:_,u_frustum_tl:o,u_frustum_tr:n,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_globe_transition:e.S(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,a,s,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.e.devicePixelRatio,this.transform.height*e.e.devicePixelRatio],r);i.setFogUniformValues(t,n);}o&&i.setCutoffUniformValues(t,o.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const s of i)t[s.key]=e[s.key]||new fs(s,512,this.transform.tileZoom,this,void 0,this.worldview);return t}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let i=this._cachedTileFogOpacities[t.key];return i||(this._cachedTileFogOpacities[t.key]=i=this.style.fog.getOpacityForTile(t)),i[0]>=e.at||i[1]>=e.at}setupDepthForOcclusion(e,t,i){const s=this.context,r=s.gl,o=!!i;var n;i||(i={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),s.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((n=this.depthRangeFor3D)[1]-n[0]),-1-2*n[0]/(n[1]-n[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),s.activeTexture.set(r.TEXTURE0),o||t.setTerrainUniformValues(s,i);}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant";}}function La(e,t){let i=!1,s=null;const r=()=>{s=null,i&&(e(),s=setTimeout(r,t),i=!1);};return ()=>(i=!0,s||r(),s)}const Ra=/(#.+)?$/;class Aa{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aV(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=La(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const t=Ma(e);if(this._hashName){const e=this._hashName;let i=!1;const s=location.hash.slice(1).split("&").map(s=>{const r=s.split("=")[0];return r===e?(i=!0,`${r}=${t}`):s}).filter(e=>e);return i||s.push(`${e}=${t}`),`#${s.join("&")}`}return `#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e);}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(Ra,this.getHashString()));}}function Ma(e,t){const i=e.getCenter(),s=Math.round(100*e.getZoom())/100,r=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),n=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h=t?`/${n}/${a}/${s}`:`${s}/${a}/${n}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const Fa={linearity:.3,easing:e.ew(0,0,.3,1)},Oa={deceleration:2500,maxSpeed:1400,...Fa},Ba={deceleration:20,maxSpeed:1400,...Fa},ka={deceleration:1e3,maxSpeed:360,...Fa},za={deceleration:1e3,maxSpeed:90,...Fa};class Ua{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.e.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.e.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const s=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=ja(i.pan.mag(),s,{...Oa,...t||{}});r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Na(r,e);}if(i.zoom){const e=ja(i.zoom,s,Ba);r.zoom=this._map.transform.zoom+e.amount,Na(r,e);}if(i.bearing){const t=ja(i.bearing,s,ka);r.bearing=this._map.transform.bearing+e.b0(t.amount,-179,179),Na(r,t);}if(i.pitch){const e=ja(i.pitch,s,za);r.pitch=this._map.transform.pitch+e.amount,Na(r,e);}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function Na(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing);}function ja(t,i,s){const{maxSpeed:r,linearity:o,deceleration:n}=s,a=e.b0(t*o/(i/1e3),-r,r),l=Math.abs(a)/(n*o);return {easing:s.easing,duration:1e3*l,amount:a*(l/2)}}class Va extends e.h{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,s={}){const r=_(t.getCanvasContainer(),i);super(e,{point:r,lngLat:t.unproject(r),originalEvent:i,...s}),this._defaultPrevented=!1,this.target=t;}}class Ga extends e.h{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,s){const r="touchend"===t?s.changedTouches:s.touches,o=g(i.getCanvasContainer(),r),n=o.map(e=>i.unproject(e)),a=o.reduce((e,t,i,s)=>e.add(t.div(s.length)),new e.P(0,0));super(t,{points:o,point:a,lngLats:n,lngLat:i.unproject(a),originalEvent:s}),this._defaultPrevented=!1;}}class qa extends e.h{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class Za{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new qa(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Va(e.type,this._map,e))}mouseup(e){this._map.fire(new Va(e.type,this._map,e));}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Va(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Va(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Va(e.type,this._map,e))}mouseover(e){this._map.fire(new Va(e.type,this._map,e));}mouseout(e){this._map.fire(new Va(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ga(e.type,this._map,e))}touchmove(e){this._map.fire(new Ga(e.type,this._map,e));}touchend(e){this._map.fire(new Ga(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ga(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class $a{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Va(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Va("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Va(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Ha{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}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&&(u(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,s=this._startPos,r=this._lastPos;if(!s||!r||r.equals(i)||!this._box&&i.dist(s)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=a("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const o=Math.min(s.x,i.x),n=Math.max(s.x,i.x),l=Math.min(s.y,i.y),c=Math.max(s.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${o}px,${l}px)`,this._box.style.width=n-o+"px",this._box.style.height=c-l+"px");});}mouseupWindow(t,i){if(!this._active)return;const s=this._startPos,r=i;if(s&&0===t.button){if(this.reset(),m(),s.x!==r.x||s.y!==r.y)return this._map.fire(new e.h("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(s,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),p(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.h(t,{originalEvent:i}))}}function Wa(e,t){const i={};for(let s=0;s<e.length;s++)i[e[s].identifier]=t[s];return i}class Xa{constructor(e){this.reset(),this.numTouches=e.numTouches;}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1;}touchstart(t,i,s){(this.centroid||s.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Wa(s,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const s=Wa(i,t);for(const e in this.touches){const t=s[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 Ka{constructor(e){this.singleTap=new Xa(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,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 s=this.singleTap.touchend(e,t,i);if(s){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(s)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=s,this.count===this.numTaps)return this.reset(),s}}}class Ya{constructor(){this._zoomIn=new Ka({numTouches:1,numTaps:2}),this._zoomOut=new Ka({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 s=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return s?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(s)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{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}}const Qa=0,Ja=2,el={[Qa]:1,[Ja]:2},tl={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class il{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=y(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=el[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&y(e)===this._eventButton&&(this._moved&&m(),this.reset());}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class sl extends il{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0);}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return {around:t,panDelta:t.sub(e)}}}class rl extends il{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?tl[e.pitchRotateKey]:void 0;}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault();}}class ol extends il{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?tl[e.pitchRotateKey]:void 0;}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault();}}class nl{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.aV(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this);}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0);}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(t,i,s){if(this._active&&!(s.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===s.length&&!e.ex())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,s)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset();}touchcancel(){this.reset();}_calculateTransform(t,i,s){s.length>0&&(this._active=!0);const r=Wa(s,i),o=new e.P(0,0),n=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),n._add(t.sub(i)),a++,r[e]=t);}if(this._touches=r,a<this._minTouches||!n.mag())return;const l=n.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"));}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset();}isEnabled(){return !!this._enabled}isActive(){return !!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=a("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");},500);}}class al{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}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){const s=this._firstTwoTouches;if(!s)return;e.preventDefault();const[r,o]=s,n=ll(i,t,r),a=ll(i,t,o);if(!n||!a)return;const l=this._aroundCenter?null:n.add(a).div(2);return this._move([n,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[s,r]=this._firstTwoTouches,o=ll(i,t,s),n=ll(i,t,r);o&&n||(this._active&&m(),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 ll(e,t,i){for(let s=0;s<e.length;s++)if(e[s].identifier===i)return t[s]}function cl(e,t){return Math.log2(e/t)}class hl extends al{reset(){super.reset(),this._distance=0,this._startDistance=0;}_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(cl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:cl(this._distance,i),pinchAround:t}}}function dl(e,t){return 180*e.angleWith(t)/Math.PI}class ul extends al{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0;}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1]);}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:dl(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return !1;const s=dl(e,i);return Math.abs(s)<t}}function pl(e){return Math.abs(e.y)>Math.abs(e.x)}class fl extends al{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,pl(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,s){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),n=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.ex()&&s.touches.length<3||(this._valid=this.gestureBeginsVertically(o,n,s.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+n.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const s=e.mag()>=2,r=t.mag()>=2;if(!s&&!r)return;if(!s||!r)return this._firstMove??=i,i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return pl(e)&&pl(t)&&o}}const ml={panStep:100,bearingStep:15,pitchStep:10};class _l{constructor(){const e=ml;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._bearingDisabled=!1,this._pitchDisabled=!1,this._panDisabled=!1,this._zoomDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;if(!this.isEnabled())return;let t=0,i=0,s=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?s=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?s=-1:(e.preventDefault(),o=1);break;default:return}return this._bearingDisabled&&(i=0),this._pitchDisabled&&(s=0),this._panDisabled&&(r=0,o=0),this._zoomDisabled&&(t=0),{cameraAnimation:n=>{const a=n.getZoom();n.easeTo({duration:300,easeId:"keyboardHandler",easing:gl,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:n.getBearing()+i*this._bearingStep,pitch:n.getPitch()+s*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:n.getCenter()},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled&&!(this._bearingDisabled&&this._pitchDisabled&&this._panDisabled&&this._zoomDisabled)}isActive(){return this._active}disableRotation(){this._pitchDisabled=!0,this._bearingDisabled=!0;}enableRotation(){this._pitchDisabled=!1,this._bearingDisabled=!1;}isRotationEnabled(){return !this._pitchDisabled&&!this._bearingDisabled}disablePan(){this._panDisabled=!0;}enablePan(){this._panDisabled=!1;}isPanEnabled(){return !this._panDisabled}disableZoom(){this._zoomDisabled=!0;}enableZoom(){this._zoomDisabled=!1;}isZoomEnabled(){return !this._zoomDisabled}disablePitch(){this._pitchDisabled=!0;}enablePitch(){this._pitchDisabled=!1;}isPitchEnabled(){return !this._pitchDisabled}disableBearing(){this._bearingDisabled=!0;}enableBearing(){this._bearingDisabled=!1;}isBearingEnabled(){return !this._bearingDisabled}}function gl(e){return e*(2-e)}const yl=4.000244140625,vl=1/450,bl=/(Mac|iPad)/i;class xl{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=vl,e.aV(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}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,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.ex()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=e.e.now(),r=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,0!==i&&i%yl===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=_(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>yl?this._wheelZoomRate:this._defaultZoomRate;let s=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==s&&(s=1/s);const r=i(),o=Math.pow(2,r),n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*s))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const s="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let n,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.e.now()-this._lastWheelEventTime)/200,1),i=o(t);n=e.al(r,s,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else n=s,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;},200));let l=n-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ey;if(this._prevEase){const t=this._prevEase,s=(e.e.now()-t.start)/t.duration,r=t.easing(s+.01)-t.easing(s),o=.27/Math.sqrt(r*r+1e-4)*.01,n=Math.sqrt(.0729-o*o);i=e.ew(o,n,.25,1);}return this._prevEase={start:e.e.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=a("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=bl.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");},200);}}class wl{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 Tl{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Sl{constructor(){this._tap=new Ka({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const s=t[0],r=s.y-this._swipePoint.y;return this._swipePoint=s,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Cl{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("mapboxgl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class El{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i,this._pitchDisabled=!1,this._rotationDisabled=!1;}enable(){this._rotationDisabled||this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._pitchWithRotate?!this._rotationDisabled&&this._mouseRotate.isEnabled()||!this._pitchDisabled&&this._mousePitch.isEnabled():!this._rotationDisabled&&this._mouseRotate.isEnabled()}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}disablePitch(){this._pitchDisabled=!0,this._mousePitch.disable();}enablePitch(){this._pitchDisabled=!1,this._pitchWithRotate&&this._mouseRotate.isEnabled()&&this._mousePitch.enable();}isPitchEnabled(){return !this._pitchDisabled&&this._mousePitch.isEnabled()}disableRotation(){this._rotationDisabled=!0,this._mouseRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._mouseRotate.enable();}isRotationEnabled(){return !this._rotationDisabled&&this._mouseRotate.isEnabled()}}class Il{constructor(e,t,i,s){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=s,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoomDisabled||this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()||!this._rotationDisabled&&this._touchRotate.isEnabled()||!this._tapDragZoomDisabled&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}isRotationEnabled(){return !this._rotationDisabled}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable();}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable();}isTapDragZoomEnabled(){return !this._tapDragZoomDisabled}}const Dl=e=>e.zoom||e.drag||e.pitch||e.rotate;class Pl extends e.h{}class Ll{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const s=e.c2([],i,t);this.radius=e.em(s[2]<0?e.eA([],s,this.constants):[s[0],s[1],0]);}projectRay(t){e.eA(t,t,this.constants),e.c3(t,t),e.eB(t,t,this.constants);const i=e.dC([],t,this.radius);if(i[2]>0){const t=e.dC([],[0,0,1],e.dF(i,[0,0,1])),s=e.dC([],e.c3([],[i[0],i[1],0]),this.radius),r=e.dD([],i,e.dC([],e.c2([],e.dD([],s,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function Rl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Al{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ua(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ll,this._dragOrigin=null,this._mouseBeingPressed=!1,this._activeTouchCount=0,this._eventsInProgress={},this._addDefaultHandlers(i),e.aV(["handleEvent","handleWindowEvent"],this);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const s=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,s,i);}}destroy(){for(const[e,t,i]of this._listeners){const s=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,s,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Za(t,e));const s=t.boxZoom=new Ha(t,e);this._add("boxZoom",s);const r=new Ya,o=new Tl;t.doubleClickZoom=new wl(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const n=new Sl;this._add("tapDragZoom",n);const a=t.touchPitch=new fl(t);this._add("touchPitch",a);const l=new rl(e),c=new ol(e);t.dragRotate=new El(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new sl(e),d=new nl(t,e);t.dragPan=new Cl(i,h,d),this._add("mousePan",h),this._add("touchPan",d,["touchZoom","touchRotate"]);const u=new ul,p=new hl;t.touchZoomRotate=new Il(i,p,u,n),this._add("touchRotate",u,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new $a(t));const f=t.scrollZoom=new xl(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new _l;this._add("keyboard",m);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e="never"){if(!this._updatingCamera&&!("always"===e||"ifPointerDown"===e&&this._isPointerDown())){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},!1),this._changes=[],this._originalZoom=void 0;}}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 !!Dl(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const s in e)if(!(s===i||t&&t.includes(s)))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}_updatePointerLiveness(e){switch(e.type){case "mousedown":this._mouseBeingPressed=!0;break;case "mousemove":0===e.buttons&&(this._mouseBeingPressed=!1);break;case "mouseup":this._mouseBeingPressed=!1;break;case "touchstart":case "touchmove":case "touchend":case "touchcancel":this._activeTouchCount=e.touches?e.touches.length:0;break;case "blur":this._mouseBeingPressed=!1,this._activeTouchCount=0;}}_isPointerDown(){return this._mouseBeingPressed||this._activeTouchCount>0}handleEvent(e,t){this._updatePointerLiveness(e),this._updatingCamera=!0;const i="renderFrame"===e.type,s=i?void 0:e,r={needsRenderFrame:!1},o={},n={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?g(this._el,a):i?void 0:_(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let d;this._blockedByActive(n,h,i)?c.reset():c[t||e.type]&&(d=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,d,i,s),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||c.isActive())&&(n[i]=c);}const c={};for(const e in this._previousActiveHandlers)n[e]||(c[e]=s);this._previousActiveHandlers=n,(Object.keys(c).length||Rl(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(n).length||Rl(r))&&this._map._stop({keepGesture:"always"}),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,s,r){if(!i)return;Object.assign(e,i);const o={handlerName:s,originalEvent:i.originalEvent||r};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o);}_applyChanges(){const t={},i={},s={};for(const[r,o,n]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,o),Object.assign(s,n);this._updateMapTransform(t,i,s),this._changes=[];}_updateMapTransform(t,i,s){const r=this._map,o=r.transform,n=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Rl(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0);}if(o._isCameraConstrained&&r._stop({keepGesture:"always"}),!Rl(t))return void this._fireEvents(i,s,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:d,aroundCoord:u,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(d=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&d&&(this._dragOrigin=n(o.pointCoordinate3D(d)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop({keepGesture:"always"}),d=d||r.transform.centerPoint,c&&(o.bearing+=c),h&&(o.pitch+=h),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1];}else {const t=o.pointCoordinate(d);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.ez(e.br(t.y))*i,f[1]=-a.y*e.ez(o.center.lat)*i;}else {const e=o.pointCoordinate(d.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y);}}const m=o.zoom,_=[0,0,0];if(l){const t=n(u||o.pointCoordinate3D(d)),i={dir:e.c3([],e.c2([],t,o._camera.position))};if(i.dir[2]<0){const s=o.zoomDeltaToMovement(t,l);e.dC(_,i.dir,s);}}const g=e.dD(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,s,!0);}_fireEvents(t,i,s){const r=Dl(this._eventsInProgress),o=Dl(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in n)this._fireEvent(e,n[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:s}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||s,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=Dl(this._eventsInProgress);if(s&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.h("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1;}}_fireEvent(t,i){this._map.fire(new e.h(t,i?{originalEvent:i}:{}));}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{this._frameId=void 0,this.handleEvent(new Pl("renderFrame",{timeStamp:e})),this._applyChanges();})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Ml="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Fl extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aV(["_renderFrameCallback"],this);}getCenter(){return new e.cz(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,s){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,{offset:t,...i},s)}panTo(e,t,i){return this.easeTo({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({zoom:e,...t},i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}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({bearing:e,...t},i)}resetNorth(e,t){return this.rotateTo(0,{duration:1e3,...e},t),this}resetNorthPitch(e,t){return this.easeTo({bearing:0,pitch: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}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return this.jumpTo({fov:e},t)}getHorizontalFieldOfView(){return this.transform.horizontalFov}cameraForBounds(t,i){t=e.eC.convert(t);const s=i&&i.bearing||0,r=i&&i.pitch||0,o=t.getNorthWest(),n=t.getSouthEast();return this._cameraForBounds(this.transform,o,n,s,r,i)}_extendPadding(e){const t={top:0,right:0,bottom:0,left:0};return null==e?{...t,...this.transform.padding}:"number"==typeof e?{top:e,bottom:e,right:e,left:e}:{...t,...e}}_extendCameraOptions(e){return (e={offset:[0,0],maxZoom:this.transform.maxZoom,...e}).padding=this._extendPadding(e.padding),e}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],s=t.max[1]-t.min[1];return i/s>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):s/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,s,r,o,n){const a=t.clone(),l=this._extendCameraOptions(n);a.bearing=r,a.pitch=o;const c=e.cz.convert(i),h=e.cz.convert(s),d=.5*(c.lat+h.lat),u=.5*(c.lng+h.lng),p=e.eD(d,u),f=e.c3([],p),m=e.c3([],e.eE([],f,[0,1,0])),_=e.eE([],m,f),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,e.eD(c.lat,c.lng),e.eD(h.lat,c.lng),e.eD(h.lat,h.lng),e.eD(c.lat,h.lng),e.eD(d,c.lng),e.eD(d,h.lng),e.eD(c.lat,u),e.eD(h.lat,u)];let v=e.eF.fromPoints(y.map(t=>[e.dF(m,t),e.dF(_,t),e.dF(f,t)]));const b=e.bH([],v.center,g);0===e.eG(b)&&e.eH(b,0,0,1),e.c3(b,b),e.dC(b,b,e.c8),a.center=e.eI(b);const x=a.getWorldToCameraMatrix(),w=e.aO(new Float64Array(16),x);v=e.eF.applyTransform(v,e.X([],x,g));const T=this._extendAABB(v,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T,e.bH(b,b,x);const S=.5*(v.max[2]-v.min[2]),C=this._minimumAABBFrustumDistance(a,v),E=e.dC([],[0,0,1],S),I=e.dD(E,b,E),D=C+(0===a.pitch?0:e.eJ(b,I)),P=a.globeCenterInViewSpace,L=e.c2([],b,[P[0],P[1],P[2]]);e.c3(L,L),e.dC(L,L,D);const R=e.dD([],b,L);e.bH(R,R,w);const A=e.bj/e.c8,M=e.em(R),F=e.dw(Math.max(M*A-e.bj,Number.EPSILON),0),O=Math.min(a.zoomFromMercatorZAdjusted(F),l.maxZoom);return O>.5*(e.e9+e.b1)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,i,s,r,o,n)):{center:a.center,zoom:O,bearing:r,pitch:o}}_extendAABB(t,i,s,r){const o=.5*((s.padding.left||0)+(s.padding.right||0)),n=.5*((s.padding.top||0)+(s.padding.bottom||0)),a=n,l=o,c=o,h=n,d=i.width-(l+c),u=i.height-(a+h),p=e.c2([],t.max,t.min),f=Math.min(d/p[0],u/p[1]),m=Math.min(i.scaleZoom(i.scale*f),s.maxZoom);if(isNaN(m))return null;const _=i.scale/i.zoomScale(m),g=new e.eF([t.min[0]-l*_,t.min[1]-h*_,t.min[2]],[t.max[0]+c*_,t.max[1]+a*_,t.max[2]]),y=("number"==typeof s.offset.x&&"number"==typeof s.offset.y?new e.P(s.offset.x,s.offset.y):e.P.convert(s.offset)).rotate(-e.au(r));return g.center[0]-=y.x*_,g.center[1]+=y.y*_,g}queryTerrainElevation(t,i){const s=this.transform.elevation;return s?(i={exaggerated:!0,...i},s.getAtPoint(e.bS.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,s,r,o,n){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,s,r,o,n);const a=t.clone(),l=this._extendCameraOptions(n);a.bearing=r,a.pitch=o;const c=e.cz.convert(i),h=e.cz.convert(s),d=new e.cz(c.lng,h.lat),u=new e.cz(h.lng,c.lat),p=a.project(c),f=a.project(h),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(d),y=this.queryTerrainElevation(u),v=[[p.x,p.y,Math.min(m||0,_||0,g||0,y||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,y||0)]];let b=e.eF.fromPoints(v);const x=a.getWorldToCameraMatrix(),w=e.aO(new Float64Array(16),x);b=e.eF.applyTransform(b,x);const T=this._extendAABB(b,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");b=T;const S=.5*e.c2([],b.max,b.min)[2],C=this._minimumAABBFrustumDistance(a,b),E=[0,0,1,0];e.c7(E,E,x),e.eK(E,E);const I=e.dC([],E,C+S),D=e.dD([],b.center,I);e.bH(b.center,b.center,w),e.bH(D,D,w);const P=a.unproject(new e.P(b.center[0],b.center[1])),L=e.eL(a.projection,P),R=Math.pow(2,L),A=Math.min(a._zoomFromMercatorZ(D[2]*a.pixelsPerMeter*R/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&A<.5*(e.e9+e.b1)?(a.setProjection({name:"globe"}),a.zoom=A,this._cameraForBounds(a,i,s,r,o,n)):{center:P,zoom:A,bearing:r,pitch:o}}fitBounds(e,t,i){const s=this.cameraForBounds(e,t);return this._fitInternal(s,t,i)}fitScreenCoordinates(t,i,s,r,o){const n=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(n.x,a.x),Math.min(n.y,a.y)),c=new e.P(Math.max(n.x,a.x),Math.max(n.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(n,a))return this;const h=this.transform.pointLocation3D(l),d=this.transform.pointLocation3D(c),u=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(h.lng,d.lng,u.lng,p.lng),Math.min(h.lat,d.lat,u.lat,p.lat)],m=[Math.max(h.lng,d.lng,u.lng,p.lng),Math.max(h.lat,d.lat,u.lat,p.lat)],_=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,s,_,r);return this._fitInternal(g,r,o)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this._stop({keepGesture:"ifPointerDown"});const s=t.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,n=!1;"zoom"in t&&s.zoom!==+t.zoom&&(r=!0,s.zoom=+t.zoom),void 0!==t.center&&(s.center=e.cz.convert(t.center)),"bearing"in t&&s.bearing!==+t.bearing&&(o=!0,s.bearing=+t.bearing),"pitch"in t&&s.pitch!==+t.pitch&&(n=!0,s.pitch=+t.pitch),"fov"in t&&(s.fov=+t.fov);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!s.isPaddingEqual(a))if(!1===t.retainPadding){const e=s.clone();e.padding=a,s.setLocationAtPoint(s.center,e.centerPoint);}else s.padding=a;return t.preloadOnly?(this._preloadTiles(s),this):(this.fire(new e.h("movestart",i)).fire(new e.h("move",i)),r&&this.fire(new e.h("zoomstart",i)).fire(new e.h("zoom",i)).fire(new e.h("zoomend",i)),o&&this.fire(new e.h("rotatestart",i)).fire(new e.h("rotate",i)).fire(new e.h("rotateend",i)),n&&this.fire(new e.h("pitchstart",i)).fire(new e.h("pitch",i)).fire(new e.h("pitchend",i)),this.fire(new e.h("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ml),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const s=this.transform;if(!s.projection.supportsFreeCamera)return e.w(Ml),this;this.stop();const r=s.zoom,o=s.pitch,n=s.bearing;s.setFreeCameraOptions(t);const a=r!==s.zoom,l=o!==s.pitch,c=n!==s.bearing;return this.fire(new e.h("movestart",i)).fire(new e.h("move",i)),a&&this.fire(new e.h("zoomstart",i)).fire(new e.h("zoom",i)).fire(new e.h("zoomend",i)),c&&this.fire(new e.h("rotatestart",i)).fire(new e.h("rotate",i)).fire(new e.h("rotateend",i)),l&&this.fire(new e.h("pitchstart",i)).fire(new e.h("pitch",i)).fire(new e.h("pitchend",i)),this.fire(new e.h("moveend",i)),this}easeTo(t,i){this._stop({easeId:t.easeId}),(!1===(t={offset:[0,0],duration:500,easing:e.ey,...t}).animate||this._prefersReducedMotion(t))&&(t.duration=0);const s=this.transform,r=this.getZoom(),o=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l=this.getVerticalFieldOfView(),c="zoom"in t?+t.zoom:r,h="bearing"in t?this._normalizeBearing(t.bearing,o):o,d="pitch"in t?+t.pitch:n,u="fov"in t?+t.fov:l,p=this._extendPadding(t.padding),f=e.P.convert(t.offset);let m,_,g;if("globe"===s.projection.name){const i=e.bS.fromLngLat(s.center),r=f.rotate(-s.angle);i.x+=r.x/s.worldSize,i.y+=r.y/s.worldSize;const o=i.toLngLat(),n=e.cz.convert(t.center||o);this._normalizeCenter(n),m=s.centerPoint.add(r),_=new e.P(i.x,i.y).mult(s.worldSize),g=new e.P(e.a7(n.lng),e.a8(n.lat)).mult(s.worldSize).sub(_);}else {m=s.centerPoint.add(f);const i=s.pointLocation(m),r=e.cz.convert(t.center||i);this._normalizeCenter(r),_=s.project(i),g=s.project(r).sub(_);}const y=s.zoomScale(c-r);let v,b;t.around&&(v=e.cz.convert(t.around),b=s.locationPoint(v));const x=this._zooming||c!==r,w=this._rotating||o!==h,T=this._pitching||d!==n,S=u!==l,C=!s.isPaddingEqual(p),E=!1===t.retainPadding?s.clone():s,I=s=>I=>{if(x&&(s.zoom=e.al(r,c,I)),w&&(s.bearing=e.al(o,h,I)),T&&(s.pitch=e.al(n,d,I)),S&&(s.fov=e.al(l,u,I)),C&&(E.interpolatePadding(a,p,I),m=E.centerPoint.add(f)),v)s.setLocationAtPoint(v,b);else {const e=s.zoomScale(s.zoom-r),t=c>r?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-I),o=s.unproject(_.add(g.mult(I*i)).mult(e));s.setLocationAtPoint(s.renderWorldCopies?o.wrap():o,m);}return t.preloadOnly||this._fireMoveEvents(i),s};if(t.preloadOnly){const e=this._emulate(I,t.duration,s);return this._preloadTiles(e),this}const D={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=w,this._pitching=T,this._padding=C,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,D),this._ease(I(s),e=>{"sea"===s.cameraElevationReference&&s.recenterOnTerrain(),this._afterEase(i,e);},t),this}_prepareEase(t,i,s={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||s.moving||this.fire(new e.h("movestart",t)),this._zooming&&!s.zooming&&this.fire(new e.h("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new e.h("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new e.h("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.h("move",t)),this._zooming&&this.fire(new e.h("zoom",t)),this._rotating&&this.fire(new e.h("rotate",t)),this._pitching&&this.fire(new e.h("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const s=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new e.h("zoomend",t)),r&&this.fire(new e.h("rotateend",t)),o&&this.fire(new e.h("pitchend",t)),this.fire(new e.h("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const s=e.cb(t,["center","zoom","bearing","pitch","fov","around","padding","retainPadding"]);return this.jumpTo(s,i)}this.stop(),t={offset:[0,0],speed:1.2,curve:1.42,easing:e.ey,...t};const s=this.transform,r=this.getZoom(),o=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l=this.getVerticalFieldOfView(),c="zoom"in t?e.b0(+t.zoom,s.minZoom,s.maxZoom):r,h="bearing"in t?this._normalizeBearing(t.bearing,o):o,d="pitch"in t?+t.pitch:n,u="fov"in t?+t.fov:l,p=u!==l,f=this._extendPadding(t.padding),m=s.zoomScale(c-r),_=e.P.convert(t.offset);let g=s.centerPoint.add(_);const y=s.pointLocation(g),v=e.cz.convert(t.center||y);this._normalizeCenter(v);const b=s.project(y),x=s.project(v).sub(b);let w=t.curve;const T=Math.max(s.width,s.height),S=T/m,C=x.mag();if("minZoom"in t){const i=e.b0(Math.min(t.minZoom,r,c),s.minZoom,s.maxZoom),o=T/s.zoomScale(i-r);w=Math.sqrt(o/C*2);}const E=w*w;function I(e){const t=(S*S-T*T+(e?-1:1)*E*E*C*C)/(2*(e?S:T)*E*C);return Math.log(Math.sqrt(t*t+1)-t)}function D(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const L=I(0);let R=function(e){return P(L)/P(L+w*e)},A=function(e){return T*((P(L)*(D(t=L+w*e)/P(t))-D(L))/E)/C;var t;},M=(I(1)-L)/w;if(Math.abs(C)<1e-6||!isFinite(M)){if(Math.abs(T-S)<1e-6)return this.easeTo(t,i);const e=S<T?-1:1;M=Math.abs(Math.log(S/T))/w,A=function(){return 0},R=function(t){return Math.exp(e*w*t)};}t.duration="duration"in t?+t.duration:1e3*M/("screenSpeed"in t?+t.screenSpeed/w:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const F=o!==h,O=d!==n,B=!s.isPaddingEqual(f),k=!1===t.retainPadding?s.clone():s,z=s=>m=>{const y=m*M,w=1/R(y);s.zoom=1===m?c:r+s.scaleZoom(w),F&&(s.bearing=e.al(o,h,m)),O&&(s.pitch=e.al(n,d,m)),p&&(s.fov=e.al(l,u,m)),B&&(k.interpolatePadding(a,f,m),g=k.centerPoint.add(_));const T=1===m?v:s.unproject(b.add(x.mult(A(y))).mult(w));return s.setLocationAtPoint(s.renderWorldCopies?T.wrap():T,g),s._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),s};if(t.preloadOnly){const e=this._emulate(z,t.duration,s);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=F,this._pitching=O,this._padding=B,this._prepareEase(i,!1),this._ease(z(s),()=>this._afterEase(i),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop({easeId:e,keepGesture:t}={}){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e);}const i=this.handlers;return i&&i.stop(t),this}_ease(t,i,s){!1===s.animate||0===s.duration?(t(1),i()):(this._easeStart=e.e.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.e.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.cU(t,-180,180);const s=Math.abs(t-i);return Math.abs(t-360-i)<s&&(t-=360),Math.abs(t+360-i)<s&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.e.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const s=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=s;e++){const t=o(e/s);r.push(t.clone());}return r}_preloadTiles(e,t){}}const Ol=/^(https?:|mailto:)/i;class Bl{constructor(t={}){this.options=t,e.aV(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=a("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=a("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const s=a("span","mapboxgl-ctrl-icon",this._compactButton);return s.setAttribute("aria-hidden","true"),s.setAttribute("title",i),this._innerContainer=a("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0;}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"));}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.eM.ACCESS_TOKEN}];if(t){const s=i.reduce((e,t,s)=>(t.value&&(e+=`${t.key}=${t.value}${s<i.length-1?"&":""}`),e),"?");t.href=`${e.eM.FEEDBACK_URL}/${s}#${Ma(this._map,!0)}`,t.rel="noopener nofollow";}}_updateData(e){!e||("source"!==e.dataType||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType)&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink());}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style._mergedSourceCaches;for(const i in t){const s=t[i];if(s.used){const t=s.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution);}}e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let s=i+1;s<e.length;s++)if(e[s].includes(t))return !1;return !0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.map(e=>function(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const s=e.getAttribute("href");if(!s||!Ol.test(s))return void e.replaceWith(t.createTextNode(i));const r=t.createElement("a");r.href=s,r.textContent=i,r.rel="noopener nofollow";const o=e.getAttribute("class");o&&(r.className=o),e.replaceWith(r);}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null);}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show");}}class kl{constructor(){e.aV(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=a("div","mapboxgl-ctrl");const t=a("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact);}getDefaultPosition(){return "bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(Object.hasOwn(i,"mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class zl{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){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=[];}}class Ul{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.ds((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const Nl={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class jl extends e.h{constructor(e,t,i,s){const{point:r,lngLat:o,originalEvent:n,target:a}=e;super(e.type,{point:r,lngLat:o,originalEvent:n,target:a}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=s;}}class Vl{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map;}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const s=i.filter;let r=i.type;s&&this.filters.set(t,e.bv(s)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const o=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===o.size&&this.map.on(r,this.handleType),0===o.size&&this.interactionsByType.set(r,o),o.set(t,i),this.typeById.set(t,r);}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType));}queryTargets(e,t){const i=[];for(const[e,s]of t)s.target&&i.push({targetId:e,target:s.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())));}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear();}handleType(t,i){const s="mouseenter"===t.type;if(s&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),o=!!i;i=i||this.queryTargets(t.point,r);let n=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const h of r){if(gr(h,l,a,i))continue;const r=new e.dl(l,h),d=_r(h,l,i);o&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const u=s?this.prevHoveredFeatures.get(d):null,p=new jl(t,i,c,r),f=u?u.stop:c.handler(p);if(s&&this.hoveredFeatures.set(d,{feature:l,stop:f}),!1!==f){n=!0;break}}if(n)break}}if(n)break}if(!n)for(const[e,i]of r){const{handler:s,target:r}=i;if(!r&&!1!==s(new jl(t,e,i,null)))break}}}function Gl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),s=new Set(i);return e.size===s.size&&t.every(e=>s.has(e))}return e.O(t,i)}const ql=/matrix.*\((.+)\)/,Zl={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},$l={showCompass:!0,showZoom:!0,visualizePitch:!1};class Hl{constructor(t,i,s=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new rl({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,s&&(this.mousePitch=new ol({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aV(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u();}move(e,t){const i=this.map,s=this.mouseRotate.mousemoveWindow(e,t),r=s&&s.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const s=this.mousePitch.mousemoveWindow(e,t),r=s&&s.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){p(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down({...e,button:e.button,type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()},_(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,_(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=g(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=g(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset();}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp();}}function Wl(t,i,s){if(t=new e.cz(t.lng,t.lat),i){const r=new e.cz(t.lng-360,t.lat),o=new e.cz(t.lng+360,t.lat),n=360*Math.ceil(Math.abs(t.lng-s.center.lng)/360),a=s.locationPoint3D(t).distSqr(i),l=i.x<0||i.y<0||i.x>s.width||i.y>s.height;s.locationPoint3D(r).distSqr(i)<a&&(l||Math.abs(r.lng-s.center.lng)<n)?t=r:s.locationPoint3D(o).distSqr(i)<a&&(l||Math.abs(o.lng-s.center.lng)<n)&&(t=o);}for(;Math.abs(t.lng-s.center.lng)>180;){const e=s.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=s.width&&e.y<=s.height)break;t.lng>s.center.lng?t.lng-=360:t.lng+=360;}return t}const Xl={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%)"},Kl=/\s+/,Yl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ql extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t={element:t,...i}),e.aV(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:s="center",color:r="#3FB1CE",scale:o=1,draggable:n=!1,clickTolerance:a=0,rotation:l=Yl.rotation,rotationAlignment:c=Yl.rotationAlignment,pitchAlignment:h=Yl.pitchAlignment,occludedOpacity:d=Yl.occludedOpacity,altitude:u=Yl.altitude}=t||{};this._anchor=s,this._color=r,this._scale=o,this._draggable=n,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=h,this._occludedOpacity=d,this._altitude=u,this._state="inactive",this._isDragging=!1,this._pointerEvents=null,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault();}),this._element.addEventListener("mousedown",e=>{e.preventDefault();});const p=this._element.classList;for(const e in Xl)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`),t&&t.className&&p.add(...t.className.trim().split(Kl)),this._popup=null;}_createDefaultMarker(){const e=a("div"),t=l("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);this._svgElement=t;const i=l("radialGradient",{id:"shadowGradient"},l("defs",{},t));l("stop",{offset:"10%","stop-opacity":.4},i),l("stop",{offset:"100%","stop-opacity":.05},i);const s=l("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=s,0===this._altitude&&t.insertBefore(s,t.firstChild),l("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},t),l("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},t),l("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.cz.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){if(e===this._altitude)return this;const t=this._altitude;return this._altitude=e||Yl.altitude,this._defaultMarker&&0===t!=(0===this._altitude)&&(0===this._altitude?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),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,s=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[s,-1*(t-i+s)],"bottom-right":[-s,-1*(t-i+s)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,e._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t,this._altitude),s=e.getFreeCameraOptions();if(!s.position)return !1;const r=s.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const s=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.f3(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(s),t.transform._terrainEnabled()&&t.style&&t.style.hasTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`;const o=this._element.style.pointerEvents;(null===this._pointerEvents?""===o:o===this._pointerEvents)&&(this._pointerEvents=r>0?"auto":"none",this._element.style.pointerEvents=this._pointerEvents),this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${Xl[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,s=this.getPitchAlignment();if(!i||!t||"map"!==s)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.f4(e.f5(i.transform,this._lngLat)),o=t.sub(e.f6(i.transform)),n=Math.abs(o.x)+Math.abs(o.y);if(0===n)return "";const a=r/n;return `rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let s=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.cz(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.cz(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);s=e.f4(Math.atan2(r.y,r.x))-90;}else s=-i.getBearing();else if("horizon"===r){const r=e.am(4,6,i.getZoom()),o=e.f6(i.transform);o.y+=r*i.transform.height;const n=t.sub(o),a=e.f4(Math.atan2(n.y,n.x));s=(a>90?a-270:a+90)*(1-r);}return s+=this._rotation,s?`rotateZ(${s}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Wl(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.style&&t.style.hasTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)));}));}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const s=this._pointerdownPos,r=this._positionDelta;if(s&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(s)<e)return;this._isDragging=!0;}this._pos=t.point.sub(r),this._lngLat=i.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.h("dragstart"))),this.fire(new e.h("drag"));}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.h("dragend")),this._state="inactive";}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp));}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||Yl.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||Yl.rotationAlignment,this._update(),this}getRotationAlignment(){return "auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||Yl.pitchAlignment,this._update(),this}getPitchAlignment(){return "auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||Yl.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const Jl={OFF:[],WAITING_ACTIVE:["waiting","active"],ACTIVE_LOCK:["active"],ACTIVE_ERROR:["waiting","active-error"],BACKGROUND:["background"],BACKGROUND_ERROR:["waiting","background-error"]},ec=e=>`mapboxgl-ctrl-geolocate-${e}`,tc=["waiting","active","active-error","background","background-error"].map(ec),ic={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},sc={maxWidth:100,unit:"metric"},rc={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},oc=/\s+/,nc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},ac=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function lc(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const s=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case "top":return new e.P(0,t);case "top-left":return new e.P(s,s);case "top-right":return new e.P(-s,s);case "bottom":return new e.P(0,-t);case "bottom-left":return new e.P(s,-s);case "bottom-right":return new e.P(-s,-s);case "left":return new e.P(t,0);case "right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const cc="undefined"!=typeof document?document.currentScript:null;e.f7(cc&&cc.src&&e.f8(cc.src)?"cdn":"other");const hc={version:e.f2,supported:function(e){return !function(e){return "undefined"!=typeof window&&"undefined"!=typeof document?Object.hasOwn?function(){const e=document.createElement("canvas");e.width=e.height=1;const t=e.getContext("2d");return !!t&&t.getImageData(0,0,1,1).width===e.width}()?function(e){return e?(void 0===s&&(s=r(!0)),s):(void 0===i&&(i=r(!1)),i)}(e)?"":"insufficient WebGL2 support":"insufficient Canvas/getImageData support":"Object.hasOwn not supported":"not a browser"}(e)},setRTLTextPlugin:e.fd,getRTLTextPluginStatus:e.fc,setSdkInfo:e.fb,addTileProvider:e.fa,Map:class extends Fl{constructor(t){e.eN.mark(e.eO.create);const i=t;if(null!=(t={...Zl,...t}).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");super(new e.eP(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._placementAlgorithm=t.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new zl,this._domRenderTaskQueue=new zl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.av(),this._locale={...Nl,...t.locale},this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Ul(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new e.eQ(t.transformRequest,t.accessToken,t.testMode);const s=e.eR(t.accessToken||e.eM.ACCESS_TOKEN);if(s&&"atlas"in s&&"number"==typeof s.atlas&&(this._tokenExpiration=s.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",e.aV(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Al(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._fontstackCompositing=t.fontstackCompositing,(t.style||!t.testMode)&&this.setStyle(t.style||e.eM.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Aa("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,{...t.fitBoundsOptions,duration:0}));}this.resize(),t.attributionControl&&this.addControl(new Bl({customAttribution:t.customAttribution})),this._logoControl=new kl,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent();}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.h(`${t.dataType}data`,t));}),this.on("dataloading",t=>{this.fire(new e.h(`${t.dataType}dataloading`,t));}),this._interactions=new Vl(this);}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.f(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const s=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return i.includes("bottom")?r.insertBefore(s,r.firstChild):r.appendChild(s),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.f(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.includes(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.h("movestart",t)).fire(new e.h("move",t)),this.fire(new e.h("resize",t)),i&&this.fire(new e.h("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.eC.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.h("zoomstart")).fire(new e.h("zoom")).fire(new e.h("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.h("zoomstart")).fire(new e.h("zoom")).fire(new e.h("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.h("pitchstart")).fire(new e.h("pitch")).fire(new e.h("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.h("pitchstart")).fire(new e.h("pitch")).fire(new e.h("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?navigator.language:e):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this._styleDirty=!0,this.style.setWorldview(e),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let s;"globe"===i&&t.zoom>=e.b1?(t.setMercatorFromTransition(),s=!0):"mercator"===i&&t.zoom<e.b1&&(t.setProjection({name:"globe"}),s=!0),s&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0));}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let i;const s=this.transform.mercatorFromTransition;i="globe"===t.name&&this.transform.zoom>=e.b1?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&s!==this.transform.mercatorFromTransition;return (i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.cz.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){const s=e=>{let i=[];if(Array.isArray(t)){const s=t.filter(e=>this.getLayer(e));i=s.length?this.queryRenderedFeatures(e,{layers:s}):[];}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const o=t=>{const o=s(t.point);o.length?r||(r=!0,i.call(this,new Va(e,this,t.originalEvent,{features:o}))):r=!1;};return {listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=t=>{s(t.point).length?r=!0:r&&(r=!1,i.call(this,new Va(e,this,t.originalEvent)));},n=t=>{r&&(r=!1,i.call(this,new Va(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:o,mouseout:n}}}{const r=e=>{const t=s(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features);};return {listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const s=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s);for(const e in s.delegates)this.on(e,s.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const s=this._createDelegatedListener(e,t,i);for(const e in s.delegates)this.once(e,s.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const s=this._delegatedListeners?this._delegatedListeners[e]:void 0;return s&&(e=>{for(let s=0;s<e.length;s++){const r=e[s];if(r.listener===i&&Gl(r.targets,t)){for(const e in r.delegates)this.off(e,r.delegates[e]);return e.splice(s,1),this}}})(s),this}queryRenderedFeatures(t,i){if(!this.style)return [];if(void 0===t||t instanceof e.P||Array.isArray(t)||void 0!==i||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],!i){const e=this.style.queryRenderedFeatures(t,void 0,this.transform),i=this.style.queryRenderedFeatureset(t,void 0,this.transform);return e.concat(i)}let s=!0;if(i.target&&(s=this._isTargetValid(i.target),s&&!i.layers))return this.style.queryRenderedFeatureset(t,i,this.transform);let r=!0;if(i.layers&&Array.isArray(i.layers)){for(const e of i.layers)if(!this._isValidId(e)){r=!1;break}if(r&&!i.target)return this.style.queryRenderedFeatures(t,i,this.transform)}let o=[];return r&&(o=o.concat(this.style.queryRenderedFeatures(t,i,this.transform))),s&&(o=o.concat(this.style.queryRenderedFeatureset(t,i,this.transform))),o}querySourceFeatures(e,t){return !e||"string"==typeof e&&!this._isValidId(e)?[]:this.style.querySourceFeatures(e,t)}queryRasterValue(e,t,i){return this._isValidId(e)?this.style.queryRasterValue(e,t,i):Promise.resolve(null)}isPointOnSurface(t){const{name:i}=this.transform.projection;return "globe"!==i&&"mercator"!==i&&e.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}addInteraction(e,t){return this._interactions.add(e,t),this}removeInteraction(e){return this._interactions.remove(e),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(e){return this._cooperativeGestures=e,this}setStyle(t,i){return i={localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing,...i},this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.fontstackCompositing===this._fontstackCompositing&&!i.config?(this.style._diffStyle(t,(s,r)=>{if(s){const r="string"==typeof s?s:s instanceof Error?s.message:s.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}else r&&this._update(!0);},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._fontstackCompositing=i.fontstackCompositing,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i={...t};t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new wo(this,i).load(e),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new wo(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.f(new Error("IDs can't be empty."))),!1):e.df(t)?(this.fire(new e.f(new Error(`IDs can't contain special symbols: "${t}".`))),!1):"__proto__"!==t&&"constructor"!==t&&"prototype"!==t||(this.fire(new e.f(new Error(`IDs can't be "${t}".`))),!1)}_isTargetValid(e){return "featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return !1;return !0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:s=1,sdf:r=!1,stretchX:o,stretchY:n,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:h}=e.e.getImageData(i);this.style.addImage(l,{data:new e.b({width:t,height:c},h),pixelRatio:s,stretchX:o,stretchY:n,content:a,sdf:r,version:0,usvg:!1});}else if(void 0===i.width||void 0===i.height)this.fire(new e.f(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`")));else {const{width:c,height:h}=i,d=i;this.style.addImage(l,{data:new e.b({width:c,height:h},new Uint8Array(d.data)),pixelRatio:s,stretchX:o,stretchY:n,content:a,sdf:r,usvg:!1,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const s=e.I.from(t),r=this.style.getImage(s);if(!r)return void this.fire(new e.f(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.e.getImageData(i):i,{width:n,height:a,data:l}=o;if(void 0===n||void 0===a)return void this.fire(new e.f(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!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.f(new Error(`The width and height of the updated image (${n}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let h=!1;r.usvg?(r.data=new e.b({width:n,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,h=!0):r.data.replace(l,c),this.style.updateImage(s,r,h);}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.f(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t));}loadImage(t,i){(async()=>{const i=await this._requestManager.transformRequest(t,e.R.Image),{data:s}=await e.a(i);return s})().then(e=>i(null,e)).catch(i);}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.f(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this._isValidId(t.id)?(this.style.addImport(t,i).catch(t=>this.fire(new e.f(new Error("Failed to add import",t)))),this):this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,s={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,s),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,s={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,s),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getLayerProperty(e,t){return this._isValidId(e)?this.style.getLayerProperty(e,t):null}setLayerProperty(e,t,i,s={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,s),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.cz.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}resetFeatureStates(e){return this.style.resetFeatureStates(e),this._update()}_selectIndoorFloor(e){this.style.indoorManager&&this.style.indoorManager.selectFloor(e);}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(e);}getIndoorTileOptions(e,t){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,s,r,o=this._container;for(;o&&(!s||!r);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(ql)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(s=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),o=o.parentElement;}this._containerWidth=s?Math.abs(e/s):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=a("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=a("div","mapboxgl-canvas-container",e);this._canvas=a("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=a("div","mapboxgl-control-container",e),s=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{s[e]=a("div",`mapboxgl-ctrl-${e}`,i);}),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const s=e.e.devicePixelRatio||1;this._canvas.width=s*Math.ceil(t),this._canvas.height=s*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const i={...t,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},s=this._canvas.getContext("webgl2",i);s?(e.eS(s,!0),this.painter=new Pa(s,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.style&&e.sourceCacheId&&this.style._buildingIndex.hasLayerForSourceCache(e.sourceCacheId)&&this.style._requestFullLabelPlacement(),this.painter.setTileLoadedFlag(!0);}})):this.fire(new e.f(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new e.h("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.h("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return !this.isMoving()&&this.loaded()}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(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);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(t){let i;this.fire(new e.h("renderstart")),++this._frameId;const s=this.painter.context.extTimerQuery,r=e.e.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=o.createQuery(),o.beginQuery(s.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const n=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,s=e.e.now(),r=new e.ai(t,{now:s,fadeDuration:n,pitch:i,transition:this._loaded?this.style.transition:{duration:0,delay:0},worldview:this._worldview});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(r),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(r),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,n,this._crossSourceCollisions,this.painter.replacementSource,this._placementAlgorithm)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming,paintStartTimeStamp:t}),this.fire(new e.h("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.eN.mark(e.eO.load),this.fire(new e.h("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.e.now()-r;o.endQuery(s.TIME_ELAPSED_EXT),setTimeout(()=>{const s=o.getQueryParameter(i,o.QUERY_RESULT)/1e6;o.deleteQuery(i),this.fire(new e.h("gpu-timing-frame",{cpuTime:t,gpuTime:s}));},50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.h("gpu-timing-layer",{layerTimes:i}));},50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.h("gpu-timing-deferred-render",{gpuTime:i}));},50);}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(a=this._updateAverageElevation(r,!0)),a)this.triggerRepaint();else {if(this._triggerFrame(!1),t&&(this.fire(new e.h("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.h("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}t&&this.style&&this.style.handleIdle();}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,e.eN.mark(e.eO.fullLoad),this._performanceMetricsCollection&&e.eT(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:this.painter.style.hasTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const s=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(s||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||s)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){const t=this.painter.context.gl;e.eS(t,!1),this._logoControl instanceof kl&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.f(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}_authenticate(){e.eU(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{t&&(t.message!==e.eV&&401!==t.status||this._revokeAuth());}),this._isTokenExpired()&&this._revokeAuth(),e.eW(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{});}_postStyleLoadEvent(){this.style.globalId&&e.eX(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&e.eY(this._requestManager._customAccessToken);}_postAddingAppearancesToStyleEvent(){e.eZ(this._requestManager._customAccessToken);}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,s=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,s),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let s=i[1]-i[0];const r=e.length/4;for(let o=0;o<t.length;o++){const n=t[o];let a=0;for(let t=0;t<n.length;t+=4)n[t]===e[t]&&n[t+1]===e[t+1]&&n[t+2]===e[t+2]&&n[t+3]===e[t+3]&&(a+=1);s+=(i[o+2]-i[o+1])*(1-a/r);}return s}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),e.e_(this.painter.context.gl),e.e$.remove(),e.f0.remove(),this._removed=!0,this.fire(new e.h("remove"));}triggerRepaint(){this._triggerFrame(!0);}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.e.frame(e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);}));}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bT(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint();}),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,e&&wt(),this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get showElevationIdDebug(){return !!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(e){this.painter&&this.painter._debugParams.showElevationIdDebug!==e&&(this.painter._debugParams.showElevationIdDebug=e,this.style&&e?this.style._reloadSources():this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,e&&wt(),this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e&&wt(),this.style&&e?this.style._reloadSources():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 showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.f1(t,i);}get version(){return e.f2}},NavigationControl:class{constructor(t={}){this.options={...$l,...t},this._container=a("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aV(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e});}),a("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e});}),a("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aV(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));}),this._compassIcon=a("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),s=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=s,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",s.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t);});}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Hl(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=a("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.E{constructor(t={}){super();const i=navigator.geolocation;this.options={geolocation:i,...ic,...t},e.aV(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=La(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=a("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),void 0!==this._geolocationWatchID&&(this.options.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("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1;}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t();}_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())}_setWatchState(e){this._watchState=e;const t=this._geolocateButton.classList;t.remove(...tc);for(const i of Jl[e])t.add(ec(i));}_setButtonTitle(e){const t=this._map._getUIString(e);this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t);}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":this._setWatchState("ACTIVE_ERROR");break;case "BACKGROUND":this._setWatchState("BACKGROUND_ERROR");}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.h("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=t,this.options.trackUserLocation)switch(this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._setWatchState(this.options.followUserLocation?"ACTIVE_LOCK":"BACKGROUND");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._setWatchState("BACKGROUND");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.h("geolocate",{coords:t.coords,timestamp:t.timestamp,...t.toJSON?{toJSON:t.toJSON.bind(t)}:{}})),this._finish();}}_updateCamera(t){const i=new e.cz(t.coords.longitude,t.coords.latitude),s=t.coords.accuracy,r={bearing:this._map.getBearing(),...this.options.fitBoundsOptions};this._map.fitBounds(i.toBounds(s),r,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.cz(t.coords.longitude,t.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(i).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.dw(1,t._center.lat)*t.worldSize,s=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.code)this._setWatchState("OFF"),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable"),void 0!==this._geolocationWatchID&&this._clearWatch();else {if(3===t.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.h("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"});},e));}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0);}_setupUI(t){void 0!==this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=a("button","mapboxgl-ctrl-geolocate",this._container),a("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t?(e.w("Geolocation support is not available so the GeolocateControl will be disabled."),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable")):this._setButtonTitle("GeolocateControl.FindMyLocation"),this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._createUserLocationMarkers(),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._setWatchState("BACKGROUND"),this.fire(new e.h("trackuserlocationend")));}),this.fire(new e.h("ready")));}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._setWatchState("WAITING_ACTIVE"),this.fire(new e.h("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._setWatchState("OFF"),this.fire(new e.h("trackuserlocationend"));break;case "BACKGROUND":this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.h("trackuserlocationstart"));}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add(ec("waiting")),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}setFollowUserLocation(t){return this.options.followUserLocation=t??ic.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.h("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._setWatchState("BACKGROUND"),this.fire(new e.h("trackuserlocationend")))),this}setShowAccuracyCircle(t){if(this.options.showAccuracyCircle=t??ic.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){const{longitude:t,latitude:i,accuracy:s}=this._lastKnownPosition.coords;this._accuracy=s,this._accuracyCircleMarker.setLngLat(new e.cz(t,i)).addTo(this._map),this._updateCircleRadius();}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(e){return this.options.showUserHeading=e??ic.showUserHeading,this._setup?(this.options.showUserHeading?void 0!==this._geolocationWatchID&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation()),this):this}setFitBoundsOptions(e){return this.options.fitBoundsOptions=e??ic.fitBoundsOptions,this}setShowUserLocation(e){return this.options.showUserLocation=e??ic.showUserLocation,this._setup?(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),!this._lastKnownPosition||void 0!==this._watchState&&"OFF"===this._watchState||this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove()),this):this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation);};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e();}).catch(console.error):e();}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation);}_createUserLocationMarkers(){this._dotElement=a("div","mapboxgl-user-location"),this._dotElement.appendChild(a("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(a("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ql({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=a("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ql({element:this._circleElement,pitchAlignment:"map"});}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(ec("waiting")),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:Bl,ScaleControl:class{constructor(t={}){this.options={...sc,...t},e.aV(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,s=t._containerWidth/2-e/2,r=t.unproject([s,i]),o=t.unproject([s+e,i]),n=r.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*n;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,n/1852,"nautical-mile"):n>=1e3?this._setScale(e,n/1e3,"kilometer"):this._setScale(e,n,"meter");}_setScale(e,t,i){this._map._requestDomTask(()=>{const s=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}(t),r=s/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(s):`${s}&nbsp;${rc[i]}`,this._container.style.width=e*r+"px";});}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=a("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0;}_setLanguage(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aV(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=a("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=a("button","mapboxgl-ctrl-fullscreen",this._controlContainer);a("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle());}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},IndoorControl:class{constructor(){e.aV(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null;}onAdd(e){return this._map=e,this._container=a("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._map.on("idle",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection();}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState()),this._map.off("idle",this._onStyleData);}}_createButton(e,t){const i=a("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t;}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.off("idle",this._onStyleData),this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null);}getDefaultPosition(){return "top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let s,r;i<=5?(s=0,r=i-1):0===this._visibleFloorStart?(s=0,r=3):this._visibleFloorStart>=i-3?(s=i-3-1,r=i-1):(s=this._visibleFloorStart,r=this._visibleFloorStart+3-1),t<s?this._visibleFloorStart=t:t>r&&(this._visibleFloorStart=t-2);}}this._lastSelectedFloorId=e.selectedFloorId;}this._render();}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);a("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const s=0===this._visibleFloorStart,r=this._visibleFloorStart>=i-3;if(s)this._createFloorButton(t[0]);else {const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);a("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}let o=[];if(o=s?t.slice(1,4):r?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),o.forEach(e=>this._createFloorButton(e)),r)this._createFloorButton(t[i-1]);else {const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);a("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t));}),i=(e.name||"").trim(),s=e.zIndex.toString(),r=i?Array.from(i).slice(0,3).join(""):s;this._setButtonTitle(t,r),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t);}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1);}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2);}this._render();}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStart<e&&(this._visibleFloorStart++,1===this._visibleFloorStart&&(this._visibleFloorStart=2),this._visibleFloorStart===e-1&&(this._visibleFloorStart=e),this._visibleFloorStart>e&&(this._visibleFloorStart=e),this._render());}}},Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(nc),t),this._altitude=this.options.altitude,e.aV(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(oc):[]);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.h("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.h("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.cz.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-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 s;for(i.innerHTML=e;s=i.firstChild,s;)t.appendChild(s);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=a("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=a("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='<span aria-hidden="true">&#215;</span>',e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,s=this._pos;if(!t||!i||!s)return "bottom";const r=i.offsetWidth,o=i.offsetHeight,n=s.x<r/2,a=s.x>t.transform.width-r/2;if(s.y+e<o)return n?"top-left":a?"top-right":"top";if(s.y>t.transform.height-o){if(n)return "bottom-left";if(a)return "bottom-right"}return n?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(t){const i=this._map,s=this._content;if(!i||!this._lngLat&&!this._trackPointer||!s)return;let r=this._container;if(r||(r=this._container=a("div","mapboxgl-popup",i.getContainer()),this._tip=a("div","mapboxgl-popup-tip",r),r.appendChild(s)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Wl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const s=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=lc(this.options.offset),o=this._anchor=this._getAnchor(r.y),n=lc(this.options.offset,o),a=s.add(n).round();i._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${Xl[o]} translate(${a.x}px,${a.y}px)`);});}if(!this._marker&&i._showingGlobe()){const t=e.f3(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(ac);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:Ql,Style:wo,LngLat:e.cz,LngLatBounds:e.eC,Point:e.P,MercatorCoordinate:e.bS,FreeCameraOptions:e.f9,Evented:e.E,config:e.eM,prewarm:function(){Sr().acquire(Qt);},clearPrewarmedResources:function(){const e=Tr;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Qt),Tr=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()"));},get accessToken(){return e.eM.ACCESS_TOKEN},set accessToken(t){e.fn(t);},get baseApiUrl(){return e.eM.API_URL},set baseApiUrl(t){e.fm(t);},get workerCount(){return Jt.workerCount},set workerCount(e){!function(e){Jt.workerCount=e;}(e);},get maxParallelImageRequests(){return e.eM.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.fl(t);},clearStorage(t){e.fk(t);},get workerUrl(){return Kt.workerUrl},set workerUrl(e){Kt.workerUrl=e;},get workerClass(){return Kt.workerClass},set workerClass(e){Kt.workerClass=e;},get dracoUrl(){return e.fj()},set dracoUrl(t){e.fi(t);},get meshoptUrl(){return e.fh()},set meshoptUrl(t){e.fg(t);},get buildingGenUrl(){return e.ff()},set buildingGenUrl(t){e.fe(t);},setNow:e.e.setNow,restoreNow:e.e.restoreNow};return hc});
var mapboxgl$1 = mapboxgl;
return mapboxgl$1;
}));